Java Reference
In-Depth Information
QUICK SUMMARY
1. False sharing can have significant performance impact on code that frequently
modifies volatile variables or exits synchronized blocks.
2. False sharing is difficult to detect. When a loop seems to be taking too long to oc-
cur, inspect the code to see if it matches the pattern where false sharing can occur.
3. False sharing is best avoided by moving the data to local variables and storing
them later. Alternately, padding can sometimes be used to move the conflicting
variables to different cache lines.
JVM Thread Tunings
The JVM has a few miscellaneous tunings that affect the performance of threads and syn-
chronization.
Tuning Thread Stack Sizes
When space is at a premium, the memory used by threads can be adjusted. Each thread has a
native stack, which is where the OS stores the call stack information of the thread (e.g., the
fact that the main() method has called the calculate() method, which has called the add()
method).
The default thread stack size for different versions of the JVM is shown in Table 9-9 . As a
general rule, many applications can actually run with a 128 KB stack size in a 32-bit JVM,
and a 256 KB stack size in a 64-bit JVM. The potential downside to setting this value too
small is that a thread with an extremely large call stack will throw a StackOverflowError .
Search WWH ::




Custom Search