RFR: 8269004 Implement ResizableResourceHashtable [v6]

Ioi Lam iklam at openjdk.java.net
Fri Jul 2 20:23:37 UTC 2021


> In HotSpot we have (at least) two hashtable designs in the C++ code:
> 
> - share/utilities/hashtable.hpp
> - share/utilities/resourceHash.hpp
> 
> Of the two, the `ResourceHashtable` API is much cleaner and most new code has been written with it. However, one issue is that the `SIZE` of `ResourceHashtable` is a compile-time constant. This makes the hash-to-index computation very fast on x64 (gcc can avoid using the slow divq instruction for modulo). However, the downside is we cannot use `ResourceHashtable` when we need a hashtable whose size is determined at run time (and, optionally, resizeable).
> 
> This PR refactors `ResourceHashtable` into a base template class `ResourceHashtableBase`, whose `size()` function can be configured by a subclass to be either constant or runtime-configurable. 
> 
> Note: since we want to preserve the performance of `hash % SIZE`, we can't make `size()` a virtual function.
> 
> Preliminary benchmark shows that this refactoring has no impact on the performance of the constant `ResourceHashtable`. See https://github.com/iklam/tools/tree/main/bench/resourceHash:
> 
> *before*
> ResourceHashtable: 2.70 sec
> 
> *after*
> ResourceHashtable: 2.72 sec
> ResizableResourceHashtable: 5.29 sec
> 
> To make sure `ResizableResourceHashtable` works, I rewrote some CDS code to use `ResizableResourceHashtable` instead of `KVHashtable`

Ioi Lam 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 11 additional commits since the last revision:

 - Merge branch 'master' into 8269004-resizeable-resource-hashtable
 - @kimbarrett review -- add ~FixedResourceHashtableStorage() = default;
 - @kimbarrett comments
 - @coleenp comments
 - @kimbarrett feedback to move the storage code to a base class
 - @coleenp comments
 - cleanup
 - step4 - implemented resizing
 - step3
 - step2
 - ... and 1 more: https://git.openjdk.java.net/jdk/compare/ee28753e...e41c7d22

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4536/files
  - new: https://git.openjdk.java.net/jdk/pull/4536/files/66c6e381..e41c7d22

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4536&range=05
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4536&range=04-05

  Stats: 44942 lines in 899 files changed: 23215 ins; 18555 del; 3172 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4536.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4536/head:pull/4536

PR: https://git.openjdk.java.net/jdk/pull/4536


More information about the hotspot-dev mailing list