-
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
[Discuss] Reducing allocations in HnswUtil::markRooted #14002
Comments
cc: @msokolov |
Interesting. The "theoretical" max depth of this stack would be the size of this graph. I suppose the stack does get large, which would explain a high no. of Array::grow calls? Would be interesting to see the impact of just setting initial capacity to half of the size of graph. |
I do think it's worth improving. Another way could be to measure empirically the stack depth - maybe it scales in a predictable way with total number of vectors? And then we can use that prediction as an initial size. We could also think of using a primitive array that grows (implement our own primitive ArrayDeque). |
Maybe
Should we be concerned about the chance of a humongous allocation (if the stack is really deep) with primitives? If not, I can give it a shot with running the same benchmarks with primitives and starting at |
I don't think switching to primitives would be worse than what we do today (which would have the same humongous allocation, only bigger). So, +1 to try it! |
Description
I was going through the nightly benchmark runs and came across this https://blunders.io/jfr-demo/indexing-1kb-vectors-2024.11.17.18.04.47/allocations-drill-down
Almost 7% of the allocations seem to be due to usage of
ArrayDeque
and autoboxing that's required to build the stack in this code:Is this something that's worth improving - seems like a low hanging fix? (I can contribute)
If it's worth improving, then:
ArrayDeque
should reduce some allocations. This code inArrayDeque::grow
looks quite wasteful in terms of allocations.Thoughts?
The text was updated successfully, but these errors were encountered: