Detect and resolve false sharing in Java on Arm Neoverse
Introduction
Understand false sharing in Java
Create and inspect the baseline
Identify the contended cache line
Add @Contended and verify contention padding
Compare baseline and padded runtimes
Next steps
Detect and resolve false sharing in Java on Arm Neoverse
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Run the
/sys/bus/event_source/devices check from the profiling instructions and confirm that it lists at least one SPE performance monitoring unit, usually arm_spe_0. If you get no output, follow the
SPE enablement instructions
and repeat the check before you run perf c2c record.Resolve the absolute path to the Java executable and derive the matching
javac from the same Java Development Kit (JDK). Use the same terminal so that compiler and runtime versions stay consistent across steps.Confirm that the report is sorted by
Peer Snoop, then inspect the line with the largest absolute peer-snoop count. Look for accesses from two or more CPUs, repeated loads and stores at offsets within the line, and activity while left-writer and right-writer run. Treat the line as a candidate because Perf C2C alone can’t prove that its address belongs to BaselineCounters.Compile with the required package export, and run the padded mode and JOL with
-XX:-RestrictContended. In the JOL output, verify that padding separates left and right into different contention groups. Keep -XX:-RestrictContended on every padded run because HotSpot otherwise ignores this application annotation.Expect the padded mode to show lower absolute peer-hit counts and often a lower median worker-phase runtime than the baseline. Don’t expect the representative values to match your system. Collect several alternating pairs, compare their medians, and examine variability before you conclude that padding helped. Also weigh any runtime improvement against the larger object size.