You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use a ThinVec wherever it lets us reduce the enclosing container's size.
Most runtime benchmarks are neutral. There are a couple where this improves performance by 1-2%, and very few where performance regresses by the same amount.
Given the memory reduction, I think this is a worthwhile tradeoff.
This is a memory usage optimization, not a performance optimization.
Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 89.52%. The percentage of expected errors that received a diagnostic held steady at 86.99%. The number of fully passing files held steady at 90/134.
I only used ThinVec in T when it helped to reduce the size of Sequence<T> or the size of an enum where T is a variant. E.g. Using a ThinVec for StmtClassDef helped reduce the size of Stmt. I didn't not change items in ExprDict, because ExprDict isn't the largest Expr variant and reducing its size is, therefore, not very meaningful.
ThinVec is smaller than a boxed slice, because it moves the capacity and length into the heap allocation. This is also one of the main downsides. Reading the length now requires a pointer dereference
These are AST nodes, so I think the data is always immutable (and I would also have naively gone for boxed slices here as well, for the same reason!). But taking up less space on the stack is obviously a very good reason to go for ThinVec, given the big memory savings here. Nice optimisation! 😃
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
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.
Summary
Use a
ThinVecwherever it lets us reduce the enclosing container's size.Most runtime benchmarks are neutral. There are a couple where this improves performance by 1-2%, and very few where performance regresses by the same amount.
Given the memory reduction, I think this is a worthwhile tradeoff.
This is a memory usage optimization, not a performance optimization.
Test plan
Existing tests