RFR (S) Allow ResourceHashtable size to be specified at runtime
Ioi Lam
ioi.lam at oracle.com
Fri Nov 9 06:35:22 UTC 2018
https://bugs.openjdk.java.net/browse/JDK-8213587
http://cr.openjdk.java.net/~iklam/jdk12/8213587-configurable-resource-hash.v01/
TL;DR: -- add a subclass to ResourceHashtable to allow the table size to be
dynamically specified when the table is constructed.
*** C++ template guru alert ***
I don't know much about C++ templates, so my attempt on doing this may be
ill-advised.
I *think* that with my patch, the performance of existing code, which uses
a statically-defined SIZE, should not be affected, as the C++ compiler
should be able to constant-propagate and reduce the new code:
ALWAYSINLINE unsigned size() const {
if (SIZE != CONFIGURABLE_SIZE) {
return SIZE;
} else {
return _configured_table_size;
}
}
ALWAYSINLINE Node** get_table() const {
if (SIZE != CONFIGURABLE_SIZE) {
return (Node**)(&_static_table[0]);
} else {
return _configured_table;
}
}
Node** lookup_node(unsigned hash, K const& key) {
unsigned index = hash % size(); <-----
Node** table = get_table();
Node** ptr = &table[index]; <-----
back to the old code:
Node** lookup_node(unsigned hash, K const& key) {
unsigned index = hash % SIZE; <-----
Node** ptr = &_table[index]; <-----
If anyone has a better way of doing this, I'd love to hear it!
Thanks!
- Ioi
More information about the hotspot-dev
mailing list