RFR: 8276662: Scalability bottleneck in SymbolTable::lookup_common()

Aleksey Shipilev shade at openjdk.java.net
Tue Nov 16 19:09:50 UTC 2021


On Mon, 15 Nov 2021 22:31:13 GMT, Derek White <drwhite at openjdk.org> wrote:

> Symbol table lookup had an optimization added when the symbol table was split into a shared table (for CDS?) and a local table. The optimization tries to track which table successfully found a symbol, so it can try that table first the next time.
> 
> Symbol table lookup is used in many JVM operations, including classloading, serialization, and reflection.
> 
> At startup time, more symbols will be from the shared table, but over time lookup can will be from a mix of local and shared symbols (eg user classes still have java.lang.String fields or subclass from java.lang.Object), resulting in multiple threads fighting over the value of this global variable.
> 
> With enough threads and cores, this can result in "true sharing" cache line contention.
> 
> This fix solves the scalability issue by checking the shared table first "early on", and when enough local symbols have been added, then check the local table first.  
> 
> Other options would also solve the the scaling problem, but may change the behavior that we're trying to optimize, or add more overhead or complexity than warranted, such as:
> - Statically preferring the shared or local table
> - Using a thread-local variable to track which table to search first
> - Using a NUMA-aware set of N variables distributed over M threads.

I have been looking at this code in JDK-8260718 too. The switching heuristics needs some work, and some experimentation. I think for this sharing fix, slapping `THREAD_LOCAL` to `_lookup_shared_first` would be enough? This would throw away any questions about the changes to switching heuristics. We have one defined already, so the fix becomes (crudely, untested):


diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp
index fa966fc7b22..edf48a2c2c1 100644
--- a/src/hotspot/share/classfile/symbolTable.cpp
+++ b/src/hotspot/share/classfile/symbolTable.cpp
@@ -93,3 +93,3 @@ static volatile bool   _has_items_to_clean = false;
 static volatile bool _alt_hash = false;
-static volatile bool _lookup_shared_first = false;
+static THREAD_LOCAL bool _lookup_shared_first = false;

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

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


More information about the hotspot-runtime-dev mailing list