forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dyno: changes to improve
--dyno-scope-bundled
performance (chapel-l…
…ang#25090) This PR makes a number of changes that serve to improve the performance of `chpl` under `--dyno-scope-bundled.` They are as follows: * Disable query tracing. This is currently done system-wide while this PR is a draft, but a merge-ready version of this PR should have some kind of build switch or configuration to disable query tracing when a release build is being created. * Deliberately leak the memory associated with the Dyno context. This one might be a bit controversial. The Dyno context's destruct -- thanks to all the memoized queries -- takes 0.1s to run. We only ever `delete` it on `clean_exit`, which means that the OS is about to reclaim memory anyway. * Reduce usage of `parentAst` in identifier lookups (specifically, the logic that checks for, and silences, warnings about nodes-in-calls (which are handled by call resolution). We already track if we're in the called expression of a call, so we can re-use that. This saves the -- costly -- `parentAst` lookups. * Adjust logic in `validateAndSetToId` to use 'ID::parentSymbolId` instead of the `idToParentId` query; the former does not require any AST knowledge, which also reduces the reliance on `idToAst`. It also helps skip some intermediate (non-scope) IDs while traversing. * Slightly re-order the checks in `astToAttributeGroup` to avoid as many `parentAst` lookups as possible. * Remove the logic that looks up `super` in scopes, since `super` is a reserved keyword with special meaning. * In certain eligible conditions, skip checking scopes in favor of returning a ("found") ID() when looking up a well-known reserved name. E.g., looking up `int` cannot result in matches anywhere but the global scope (since `int` is a reserved keyword), so there's no reason to look it up in user modules. * Rewrite the computation for transitively finding method receivers from inheritance chains to be recursive and re-use previous results. The net result is that the following invocation: ``` chpl --no-compiler-driver --dyno-scope-bundled examples/hello.chpl --stop-after-pass=parseAndConvertUast ``` Went from 1.3 seconds to 0.9 seconds on my local machine. This is a step forward, but is far from the 0.4s of the `--no-dyno-scope-resolve --stop-after-pass=scopeResolve` version of this command. ## Other notes * Unsurprisingly, most of the time (900ms / 1.3s of the original execution) is spent in `doLookupInScope` * From there, `scopeResolveFunction` takes 75% of the total execution time of `parseAndConvertUast` * According to query timings, the `resolveVisibilityStmtsQuery` is still among the slowest self-queries we have (i.e., excluding child execution times). This might be unsurprising since it runs the non-query `doLookupInScope`. * Noticed some minor overheads from constructing QueryMapResults. Tried switching them to use small pointer sets and small vectors, but that hurt instead of helping. At this point, it seems like we might need some sort of lookup cache, since identifiers are looked up within modules many times. This is complicated by the fact that instead of "checked module for X", we have "checked module for X given the following filter flags", which makes it harder to detect when we can be sure that a symbol doesn't exist in a scope. Reviewed by @mppf -- thanks! ## Testing - [x] paratest
- Loading branch information
Showing
19 changed files
with
466 additions
and
396 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.