This repository was archived by the owner on Nov 4, 2023. It is now read-only.
Optimised GetDecl process for faster semanting across multiple files#86
Open
JocelynSachs wants to merge 5 commits intoblitz-research:developfrom
Open
Optimised GetDecl process for faster semanting across multiple files#86JocelynSachs wants to merge 5 commits intoblitz-research:developfrom
JocelynSachs wants to merge 5 commits intoblitz-research:developfrom
Conversation
Added caching of indirectly accessible decls to speed up semanting on projects with large numbers of files.
Used by optimised ModuleDecl.GetDecl.
Optimised ModuleDecl.GetDecl
ALL caches are now dirtied when a module has decls added (since those caches could contain indirect references that are now out of date.
Thanks Anthony for the heads up.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I discovered a significant speed-bump in the semanting process: every time a declaration made in file A is used in file B, the compiler rebuilds the entire import hierarchy of file B from scratch and searches every declaration map individually for conflicts.
In practice, this resulted in a near-linear relationship between number of files and semanting time for any given quantity of code.
This modified implementation improves performance by constructing the import hierarchy of file B just once, the first time a declaration is sought outside the file. From this it caches a single map of synonyms (lists of decls with the same identifier).
Subsequently, seeking an external decl requires only a single string map lookup to obtain the appropriate synonym list. In correct code, only one synonym will pass the final accessibility test. If more than one pass, a duplicate identifier error is reported (via the old method, both for simplicity and to sanity-check the behaviour of the new system)
The upshot is a considerable reduction in semanting time on projects with large numbers of source files (from 45 seconds to under 3 seconds in our case).