-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8300184: Optimize ResourceHashtableBase::iterate_all using _number_of_entries #12016
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
Conversation
👋 Welcome back xliu! A progress list of the required criteria for merging this PR into |
Webrevs
|
Thread::name() isn't safe in gtest. We don't need the log line.
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 seems quite reasonable to me.
Thanks.
Nit: the bug synopsis says |
@navyxliu This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 332 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Hi, David, Thank you for reviewing this patch.
This is intentional. iterate_all() calls iterate() with a lambda '()->true'. For iterate(), there are two cases. If the lambda returns constant value true, it mandates iterate() to traverse all elements. By contrast, user-defined lambdas could return false and stop iterating immediately. This patch only optimizes the former case. That's why I claim to optimize iterate_all rather than iterate. Sometimes, we need to traverse all elements. eg. we want to print out the contents, copy hashable or do statistics. thanks, |
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.
Thanks!
/integrate |
Going to push as commit 0b9ff06.
Your commit was automatically rebased without conflicts. |
A call to |
Current implementation needs to visit all buckets. In extreme case, an empty hashtable with 1k buckets. iterate_all() loads 1k buckets for nothing.
_number_of_entries
is the number of nodes in the hashtable. This patch leverages that to quit iteration earlier. The real effect is up to the distribution of nodes among buckets.I also included a debug log in the original patch. It was used for the observation in the following section, but I deleted it because it introduces circular dependency.
Evaluation
In release build, the patch is very marginal. class loading do use ResourceHashtable but they are saturated.
I use it to run
Renaissance/finagle-http
. hahstable iterate_all quits a little bit earlier and save some loads. eg. in line 2, there are 109 buckets in the hashable. the iteration quit at 68th bucket, we save 42 loads.Another application is in AsyncLog Thread. We have a hashtable with 17 buckets. Each Log Output creates one node in the hashtable. In common cases, there are only 2~3 nodes in the hashtable. Each time AsyncLog Thread flushes the buffer, it has to scan the hashtable twice. Saving loads means saving the memory bandwidth for the application.
In fastdebug build, extra verification is deployed. It's common to observe that JVM scan an empty hashtable. It's in destroy_VM.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12016/head:pull/12016
$ git checkout pull/12016
Update a local copy of the PR:
$ git checkout pull/12016
$ git pull https://git.openjdk.org/jdk pull/12016/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12016
View PR using the GUI difftool:
$ git pr show -t 12016
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12016.diff