-
-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(semantic): initialize builder storage with pre-allocated capacity #4332
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
CodSpeed Performance ReportMerging #4332 will degrade performances by 6.1%Comparing Summary
Benchmarks breakdown
|
@overlookmotel |
@DonIsaac Ha! By chance, Dunqing has been working on exactly the same thing today, but taking a slightly different approach - #4328. It's unfortunate his PR title is quite mysterious "test: visit" so you didn't see it - I think he intended it initially as a quick temporary test. But... actually it's quite useful you've investigated this other heuristic approach because Dunqing's approach has run into same problem you have here with Let's join forces! I'll post more comment on #4328 to continue the conversation in one place. |
Love it! LMK if you're reachable on Discord as well. CC: @Dunqing |
function_stack: Vec::with_capacity(4), | ||
// Most TS modules are not nested, and those that are are usually only 1 level deep. | ||
namespace_stack: Vec::with_capacity(2), | ||
nodes: AstNodes::with_capacity(source_text.len() >> 4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DonIsaac Just a side note: There's no need to write >> 4
here. When you multiply or divide by a power of 2, the compiler will convert that to a bitshift operation. So writing / 16
is preferable, as it's easier to read for us humans, and results in same assembly.
What This PR Does
Initializes
nodes
,scopes
,symbols
, and several other internal stacks with some capacity already allocated. This should reduce the number of re-allocationsSemantic
needs to make while traversing a program.