-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use smol_str
for Identifier
#12099
Use smol_str
for Identifier
#12099
Conversation
CodSpeed Performance ReportMerging #12099 will improve performances by 6.89%Comparing Summary
Benchmarks breakdown
|
ec946e3
to
6e3c81a
Compare
|
Closing in favor of #12101 which shows the most promising results. |
One more time. Trying to use
smol_str
forIdentifier
s to avoid heap allocations for strings shorter than 24 characters.I also expect this to help with
red_knot
where the symbol table can't store string slices for symbol names. Instead, the symbol table clones the identifier name which isO(1)
forsmol_str
.Edit: It should be possible to store a
&Name
in the symbol table, now that salsa supports the&'db
lifetime. That means,O(1)
cloning is not as important anymore.Performance improvement
I think the performance improvement mainly comes from the removed
Box<str>
toString
conversion in the hotparse_name
function. It would be possible to remove that conversion by changingExprName
to store aBox<str>
.For a comparison, #12100 uses a
Box<str>
instead of aSmolStr
. The parser improvements are not as significant. But no linter benchmark regress.General observation:
ExprName
identifierdrop
Name
now requires branching