-
Notifications
You must be signed in to change notification settings - Fork 182
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
Favor SmallVec over Box in pluralrules #285
Conversation
components/pluralrules/Cargo.toml
Outdated
@@ -17,6 +17,7 @@ include = [ | |||
[dependencies] | |||
icu-locale = { path = "../locale" } | |||
icu-data-provider = { path = "../data-provider" } | |||
smallvec = "1.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.
This is the same version as num-util
is using.
Pull Request Test Coverage Report for Build 073a029aff20c87865f0223c207d4a4e19125dac-PR-285
💛 - Coveralls |
It seems that the linter is not liking what this does to the |
Thanks for the contribution! Can you provide figures on how "cargo bench" differs before and after this PR? Boxing the PluralRuleList seems like a good idea. It's one heap allocation, but that's better than the dozens that were there before. |
It does seem to have a nice impact on the microbenchmark:
|
In terms of long term maintenance, there's an effort now to introduce stack based vector - rust-lang/rfcs#2990 which, if successful, is a stepping stone to a hybrid vector like So I'm cautiously optimistic that we can use |
I rebased @gregtatum patch on top of master and checked it against the
I was able to reproduce that change (improvement on parsing by over 30% and regression on full selection by ~5-10%) in 5 test runs. I dove deeper:
I'm not sure what's going on here really. My first hypothesis was that the regression is in selection because accessing AST nodes is slower, but the deep benchmarks show clearly that the regression is on parsing, not selection. |
can someone reproduce? |
One hypothesis that could explain that is that my We may want to get rid of the |
If that hypothesis holds, then this PR helps Polish rules (by 30%) but slows down rules for 10 locales (by 5-10%). Both are syntentic microbenchmarks, but that would make me be against landing this change. |
Ok, I'm fairly certain that this is the case. The path forward is for #227 to be resolved and then all plural rules tests will use the generated data for the 10+/- locales we select for all benchmarks. For this PR, I suggest @gregtatum that you test against the plural rules subset or, if you want to help clean up benchmarks, take on the PR to move |
My PR in #295 is coalescing benchmarks to be more reliable by testing against 10 locales, instead of just one. Shane in #296 introduces "testdata" which will give us a single source of those locales and data to be used in all components tests/examples/benchmarks. This should help us reason about this PR, so I'd suggest now to wait for those two to land. |
It seems to reproduce on my machine (macOS).
|
Is PR #295 the one you were suggesting I look at, @zbraniecki ? I'd be happy to follow-up with some more work here, but my cadence will be a bit slower, as I'm doing this on the side. Or were you suggesting a separate issue #? |
No worries. Yeah, #295 is what I had in mind. Let's wait for it to land and then get back to this PR and decide on it! |
Can you rebase this PR on top of master? |
0052021
to
770c3d0
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
Sure thing. |
This may also be a solution once it gets merged? rust-lang/rfcs#2990 |
This will help avoid heap allocations as most lists are only a few items long. The only boxed slice that was retained was the SampleRanges, as this can be of an indeterminate length.
770c3d0
to
841c72d
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
Now that #1240 has landed, should we close this PR and the corresponding ticket as obsolete? |
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.
(setting review bit)
|
This is obsolete because now we use VarZeroVec for runtime. |
This will help avoid heap allocations as most lists are only a few items
long. The only boxed slice that was retained was the SampleRanges, as
this can be of an indeterminate length.
Resolves #193
Depends on #140
Depends on #107