Add hashmap-vs-concurrenthashmap module: JDK 25 sizeCtl/treeify internals, forced and measured lost updates

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7rnC7jppGGdHGESvy
This commit is contained in:
2026-10-28 18:07:37 +00:00
co-authored by Claude Sonnet 5.5
parent 715036b640
commit f80e1079a8
24 changed files with 958 additions and 0 deletions
@@ -0,0 +1,22 @@
threads=8, increments per thread=200,000, rounds=5, cores=2
Counts below VARY from run to run. Only the 'expected' column is fixed.
HashMap get+put expected 1,600,000 actual per round: 228,496 400,000 287,091 1,200,000 451,357
lost updates per round: min 400,000, max 1,371,504
Collections.synchronizedMap get+put expected 1,600,000 actual per round: 282,588 398,788 918,560 433,831 691,994
lost updates per round: min 681,440, max 1,317,412
ConcurrentHashMap get+put expected 1,600,000 actual per round: 214,096 666,429 605,316 446,831 389,717
lost updates per round: min 933,571, max 1,385,904
HashMap + synchronized(map) around get+put expected 1,600,000 actual per round: 1,600,000 1,600,000 1,600,000 1,600,000 1,600,000
lost updates per round: min 0, max 0
ConcurrentHashMap merge(KEY, 1, Integer::sum) expected 1,600,000 actual per round: 1,600,000 1,600,000 1,600,000 1,600,000 1,600,000
lost updates per round: min 0, max 0
ConcurrentHashMap compute(KEY, v+1) expected 1,600,000 actual per round: 1,600,000 1,600,000 1,600,000 1,600,000 1,600,000
lost updates per round: min 0, max 0
-- second kind of damage: threads insert DIFFERENT keys, nobody overwrites anybody --
HashMap put of distinct keys (size()) expected 400,000 actual per round: 399,522 400,000 400,000 400,000 400,000
lost updates per round: min 0, max 478
HashMap exceptions thrown inside worker threads, per round: [null, null, null, null, null]
ConcurrentHashMap put of distinct keys (size()) expected 400,000 actual per round: 400,000 400,000 400,000 400,000 400,000
lost updates per round: min 0, max 0