perf: memoise [Lib.closure] keyed on (linking, for_, libs)#14521
Draft
robinbb wants to merge 1 commit into
Draft
perf: memoise [Lib.closure] keyed on (linking, for_, libs)#14521robinbb wants to merge 1 commit into
robinbb wants to merge 1 commit into
Conversation
This was referenced May 13, 2026
ee1f8ce to
58ed81a
Compare
215bfef to
bf10fd7
Compare
58ed81a to
ec1ccdb
Compare
bf10fd7 to
6470974
Compare
The per-module filter calls [Lib.closure] twice per consumer module (once for [direct_libs], once for [must_glob_libs]) on each compile rule. Across a cctx, many modules pass overlapping inputs to these closures; without memoisation every call re-traverses the dependency graph. [Lib.closure] is now defined as [Memo.exec] over a [Memo.create] keyed on [(bool * Compilation_mode.t * t list)]. The list-of-libs key is order- and multiplicity-sensitive, so callers that share inputs need to canonicalise (sort by [Lib.compare]) for maximum cache reuse — [lib_deps_for_module] already does this at both call sites. A docstring on [val closure] notes the requirement. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
ec1ccdb to
8054767
Compare
6470974 to
4f3d261
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 9 of 9 of #14492. Pure performance.
Lib.closureis now defined asMemo.execover aMemo.createkeyed on(linking, for_, libs). The per-module filter callsLib.closuretwice per consumer module (once fordirect_libs, once formust_glob_libs); without memoisation every call re-traverses the dependency graph.The list-of-libs key is order- and multiplicity-sensitive — callers that share inputs (e.g.
lib_deps_for_moduleat both call sites) need to canonicalise viaList.sort_uniq ~compare:Lib.compare; the existing call sites already do.Stack: rebases on #14520. Final layer of the stack.
Part of #14492. Related to #4572.