Repository navigation
perf: intern parentDecl strings when decoding ModuleRefs from JSON - #16338
Closed
kmehltretter82 wants to merge 1 commit into
Closed
kmehltretter82 wants to merge 1 commit into
kmehltretter82 wants to merge 1 commit into
Conversation
When loading an .ilean file, Json.parse allocates a separate String for each location's parentDecl entry, and FromJson ModuleRefs previously retained all of those duplicate strings even though many references within a module share the same enclosing declaration. Thread a temporary Std.HashSet String across ModuleRefs (and standalone RefInfo) JSON decoding so that repeated parentDecl names within a module retain a single shared String object after the intermediate Json value is released. Also reuse the already computed parentDeclNameString? in RefInfo.toLspRefInfo instead of converting parentDeclName? to a String twice.
Contributor
|
Thank you for your interest in contributing to Lean! This repository currently only accepts pull requests from regular contributors, primarily from the Lean FRO, so this PR has been closed automatically. If you have found a bug or want to propose a change, please open an issue describing it instead; see also our contribution guidelines. A maintainer may reopen this PR if appropriate. |
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 interns
RefInfo.Location.parentDeclstrings across a module when decodingModuleRefs(and standaloneRefInfo) from JSON, so that locations sharing the same enclosing declaration within a loaded.ileanmodule retain a single sharedStringallocation after the intermediateJsonvalue is released. It also reuses the already computedparentDeclNameString?inRefInfo.toLspRefInfoinstead of convertingparentDeclName?to aStringtwice.Closes #16100.
Benchmarks
Measured on native compiled code (
lean -c+leanc -O3, average of 20 runs) acrossJson.parsefollowed byFromJson ModuleRefsafter releasing the intermediateJsonvalue:parentDeclsparentDeclStrings (Before → After)parentDeclBytes (Before → After)fromJson?avg (Before → After)Json.parse+fromJson?avg (Before → After)400idents ×25usages, ~808 KB JSON)10,400→50892,320 B→4,290 B(-99.5%)2.41 ms→2.95 ms9.95 ms→10.47 ms100idents ×200usages, ~1.43 MB JSON)20,100→101,708,500 B→850 B(-99.95%)4.32 ms→5.15 ms19.63 ms→19.25 ms400idents ×25usages, ~830 KB JSON)10,400→10,400914,490 B→914,490 B(0%)3.44 ms→5.06 ms12.43 ms→14.87 ms