RFR: 8301136: Improve unlink() and unlink_all() of ResourceHashtableBase [v6]
Xin Liu
xliu at openjdk.org
Tue Mar 7 05:04:09 UTC 2023
The message from this sender included one or more files
which could not be scanned for virus detection; do not
open these files unless you are certain of the sender's intent.
----------------------------------------------------------------------
On Tue, 7 Mar 2023 04:34:37 GMT, Xin Liu <xliu at openjdk.org> wrote:
>> 1. Apply the same idea of JDK-8300184 to unlink().
>> 2. Because ResourceHashtableBase doesn't support copy assignment, client of it has to purge all elements first when it needs to assign it. We would like provide a specialized version called 'unlink_all()'. We don't need to update each node's _next in this case. We only nullify all buckets.
>> 3. This patch also provides a specialized version of unlink_all() for destructor. We don't even update buckets. it's dead anyway.
>
> Xin Liu has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
>
> - Add log to dump information in removal APIs.
> - Merge branch 'master' into JDK-8301136
> - Add lambda API unlink(Function f) per reviewers' request.
> - Use unlink_all() in JvmtiTagMapTable::clear.
> - Add a template for unlink(), unlink_all() and dtor.
> - Quit early if cnt is zero.
> - 8301136: Improve unlink() and unlink_all() of ResourceHashtableBase
I uploaded the hashtable logs of Renaissance/finagle-chirper. The reason I looked in it is that it produces the most logs in runtime. It yields 14,422 lines of log for the tag 'hashtables'. One interesting thing is that 9,166 or 63.5% of them is to remove an empty ResourceHashable.
$awk -F '[ ,]' '$15 == 0 {print $0}' finagle-chirper-hashtables.log | wc -l
9166
"break at 0" below indicates that we effectively skip any iteration.
[2.151s][debug][hashtables] ResourceHashtableBase table_size = 1031, break at 0, removed 0 out of 0
For the remaining non-trivial entries, 5254 out of 5256 is to remove all elements. They are all from destructor. Current patch only invokes `unlink_all()` in JVMTI. We don't use jvmti in the test.
awk -F '[ ,]' '$12 == $15 {print $0}' finagle-chirper-hashtables-nontrivial.log|wc -l
5254
Overall, 14,063 or 97.5% of logs breaks earlier and save some useless iterations.
awk -F '[ ,]' '$5 != $9 {print $0}' finagle-chirper-hashtables.log | wc -l
14063
Conclusion:
1. We need to optimize 'destructor' of resourceHashtable. In particular, we should apply the optimization of JDK-8300184 to it.
2. we should consider to specialize "unlink_all".
-------------
PR: https://git.openjdk.org/jdk/pull/12213
More information about the hotspot-dev
mailing list