perf: cache filtered include flags per [(lib_mode, kept_libs)]#14519
Draft
robinbb wants to merge 1 commit into
Draft
perf: cache filtered include flags per [(lib_mode, kept_libs)]#14519robinbb wants to merge 1 commit into
robinbb wants to merge 1 commit into
Conversation
This was referenced May 13, 2026
c50afa4 to
38a7871
Compare
d0903f5 to
7205127
Compare
[Compilation_context.Filtered_includes] caches the [Action_builder.t] returned by [filtered_include_flags] keyed on [(lib_mode, kept_libs)]. Two modules in the same cctx that reach the same set of kept libs share one builder; [Action_builder.memoize] dedupes its evaluation. Cache key omits the cctx's [requires_compile] / [requires_hidden] — they're immutable on the cctx from [create]. The [for_module_generated_at_link_time] exception, where derived cctxs could in principle alter the closure, takes [can_filter = false] in [lib_deps_for_module] and so never reaches this function. [Filtered_includes.Key]: [lib_mode] + [kept_libs : Lib.t list] (the caller passes a sorted list via [Lib.Set.to_list], canonicalising for the cache). [equal] and [hash] derived from the same; [Repr]-derived [to_dyn] for diagnostics. [Lib_mode.hash]: new — used by [Filtered_includes.Key.hash]. Three constants for the three variants ([Ocaml Byte], [Ocaml Native], [Melange]). Signed-off-by: Robin Bate Boerop <me@robinbb.com>
38a7871 to
8634a30
Compare
7205127 to
e28b521
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Layer 7 of 9 of #14492. Pure performance.
Compilation_context.Filtered_includescaches theAction_builder.treturned byfiltered_include_flagskeyed on(lib_mode, kept_libs). Two modules in the same cctx that reach the same set of kept libs share one builder;Action_builder.memoizededupes its evaluation.Lib_mode.hash: new — used by the cache key.Stack: rebases on #14518. Next: #14520.
Part of #14492. Related to #4572.