Encoding the heap region ID into the name of the per-region mutex adds some overhead for each region. Most usage of mutexes like this provide just a static string describing the purpose of the mutex, e.g:
diff -r b588772dff7a src/hotspot/share/gc/g1/heapRegionRemSet.cpp
--- a/src/hotspot/share/gc/g1/heapRegionRemSet.cpp Thu Apr 02 15:05:24 2020 +0200
+++ b/src/hotspot/share/gc/g1/heapRegionRemSet.cpp Thu Apr 02 15:38:38 2020 +0200
@@ -373,7 +373,7 @@
HeapRegion* hr)
: _bot(bot),
_code_roots(),
- _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Mutex::_safepoint_check_never),
+ _m(Mutex::leaf, "HeapRegionRemSet lock", true, Mutex::_safepoint_check_never),
_other_regions(&_m),
_hr(hr),
_state(Untracked)
This would remove ~15% of the remaining per-region startup execution overhead.