Repository navigation
perf: skip native symbol lookups for interpreted modules - #16467
Merged
Merged
Conversation
`runInitAttrs` looked up the native initializers of every imported module, mangling two symbol names and calling `dlsym` for each in module mode. As the native initializer of a module references those of all its direct imports, a module importing one without native code cannot have native code either, so we now skip the lookup for it. On Mathlib this leaves only the modules directly above the natively compiled core. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `interpreter.prefer_native` (the default), the interpreter mangled the name of every called declaration and looked up its boxed and unboxed symbols with `dlsym`. `runInitAttrs` now records the imported modules it found to have no native code, and the interpreter skips the lookup for their non-`extern` declarations. Loading a dynamic library resets the record, as it may provide native code for such modules. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The adaptation PR for this PR is leanprover/downstream-lean4#243. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kha
marked this pull request as ready for review
November 15, 2026 12:13
Kha
enabled auto-merge
November 15, 2026 12:13
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.
This PR speeds up importing and interpreting code from modules that have no native code, such as those of most packages, by no longer looking up native initializers and symbols for them. On Mathlib, this reduces total build instructions by 2.9%.
The native initializer of a module references those of all its direct imports, so
runInitAttrsnow skips the initializer lookup for a module importing one without native code. The interpreter also no longer mangles and looks up the native symbols of non-externdeclarations from such modules; loading a dynamic library resets this, as it may provide native code for them.