-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Missing Performance Optimization for toArray of size zero #3209
Comments
Can you send us a pull request with this improvement? |
Hi, I can send a pull request, but will there be a problem as I have to remove the final modifier from |
I think at least a proof of concept would help clarify what approach you have in mind, that we can then figure out how to integrate more fully. |
Great. I've added a PR: #3213. The PR doesn't address RegularImmutableAsList implementation which would probably want to defer to the delegateList similarly to |
…/blog/2016/arrays-wisdom-ancients/, the key goal being to avoid the necessity of zeroing a newly created array where possible. Addresses #3209. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=207635563
…/blog/2016/arrays-wisdom-ancients/, the key goal being to avoid the necessity of zeroing a newly created array where possible. Addresses #3209. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=207635563
Hi all. Is this issue still actual? |
Looks like the issue has been addressed, but I haven't rerun the benchmarks with the latest changes. |
After reading “Arrays of Ancient Wisdom” I was curious as to
ImmutableList
's andImmutableSet
's performance. It turns out the zero case,listOfStrings.toArray(new String[0])
, is not optimized for array backed collections asImmutableCollection
's will create a new array of appropriate size so we don't get the use ofArrays.copyOf(src, size, Foo[].class)
mentioned in the article. I ran the same benchmark tests as the post but withImmutableSet
andImmutableList
. InterestinglyImmutableSet
is way more performant thanHashSet
's implementation. Locally, I've added overridingRegularImmutableList
to useArrayList
's implementation oftoArray
to see the performance gain.The following is with the toArray optimization and we see the performance improvement.
The text was updated successfully, but these errors were encountered: