gatherers/: windowFixed, windowSliding, fold, scan, mapConcurrent, a custom Gatherer (dedupeConsecutive, takeUntil), and a Collector-vs-Gatherer comparison. Verified: windowSliding emits one short window on a too-short stream rather than shrinking to empty like windowFixed; mapConcurrent waits for in-flight siblings to finish (~901ms) rather than cancelling them when one mapper throws. scoped-values/: ScopedValue API and rebinding, why plain threads (virtual or platform) do not inherit a binding while a StructuredTaskScope subtask does, and the memory cost vs InheritableThreadLocal measured two ways -- a noisy heap-delta first pass, then a precise jcmd GC.class_histogram object census (5 shared Carrier objects vs ~700,000 copied ThreadLocalMap/Entry objects for 100,000 threads). Companion code for the ankurm.com posts "Java Stream Gatherers (JEP 485)" and "Scoped Values vs ThreadLocal in Java 25: Migration Guide with Virtual Threads". Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FtpJvZfg4nvLvtzgJTDWpB
16 lines
1.3 KiB
Plaintext
16 lines
1.3 KiB
Plaintext
$ jcmd <pid> GC.class_histogram (100000 subtasks parked, mode=tl, JDK 25)
|
|
1: 100000 109386560 jdk.internal.vm.StackChunk ([email protected])
|
|
2: 100000 16800000 java.lang.VirtualThread ([email protected])
|
|
3: 500005 16000160 java.lang.ThreadLocal$ThreadLocalMap$Entry ([email protected])
|
|
4: 100001 8000080 [Ljava.lang.ThreadLocal$ThreadLocalMap$Entry; ([email protected])
|
|
9: 100001 2400024 java.lang.ThreadLocal$ThreadLocalMap ([email protected])
|
|
12: 100000 2400000 java.util.concurrent.StructuredTaskScopeImpl$SubtaskImpl ([email protected])
|
|
177: 5 80 java.lang.InheritableThreadLocal ([email protected])
|
|
179: 5 80 java.lang.ScopedValue ([email protected])
|
|
258: 1 32 java.util.concurrent.ThreadLocalRandom ([email protected])
|
|
281: 1 24 java.util.concurrent.StructuredTaskScopeImpl$SubtaskImpl$AltResult ([email protected])
|
|
292: 1 24 jdk.internal.vm.ScopedValueContainer$BindingsSnapshot ([email protected])
|
|
324: 1 16 java.lang.ThreadLocal ([email protected])
|
|
353: 1 16 java.util.concurrent.ThreadLocalRandom$Access$1 ([email protected])
|
|
Total 1770749 179468208
|