JDK-8261690 : NMT: AllocationSite::equals() should compare the whole object
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2021-02-13
  • Updated: 2021-07-09
  • Resolved: 2021-07-09
Related Reports
Relates :  
Description
`AllocationSite` contains a call stack and a MEMFLAGS object. `AllocationSite::equals()` only compares the call stack, disregarding the MEMFLAGS setting.

In theory two objects with the same call stack should always have the same MEMFLAGS value too since the call stack should refer to the same allocation call site. However, the call stack grabbing may have been off, we may have skipped or lost too many low frames. 

(We see this actually happening on some platforms, see [1])

The effect could be that multiple allocation sites get lumped together and registered with the same call stack. But they may carry different flags.

The flag values are currently compared outside of `AllocationSite::equals()` in `MallocSiteTable::lookup_and_add()`. But `AllocationSite`objects are placed into sorting containers too and therefore `AllocationSite::equals()` should do the comparison.

[1] https://bugs.openjdk.java.net/browse/JDK-8261556


Comments
I don't have the time to follow up on this for now. The patch would be simple, but since the whole NMT callstack code is fragile wrt to tests - relying on outguessing the C++ compiler's inlining decisions - NMT changes tend to lead to time costly test fixes. We can reopen this if needed.
09-07-2021