Skip to content

MergeOperator: per-operator scratch buffers instead of a ThreadLocal - #358

Merged
dfa1 merged 1 commit into
mainfrom
merge-operator-scratch
Nov 18, 2026
Merged

dfa1 merged 1 commit into
mainfrom
merge-operator-scratch

Conversation

@dfa1

@dfa1 dfa1 commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • MergeOperator.Custom's ThreadLocal<MemorySegment> SCRATCH is replaced by a per-State ConcurrentHashMap<Thread, ScratchBuffer>, the shape CompactionFilter already uses: buffers are reused and grown (doubling), buffers of dead threads are pruned past 64, and destructorDispatch closes every arena when RocksDB drops the operator, so nothing stays pinned on RocksDB's long-lived threads afterwards.
  • Fixes Sonar S5164 (MergeOperator:178) without a suppression. A stale CompactionFilter comment contrasting the two is updated.

Test plan

  • ./mvnw test -pl core -am, ./mvnw package -pl core -am -DskipTests
  • CI on all platforms, then re-run the Sonar workflow

🤖 Generated with Claude Code

…Local

Same shape as CompactionFilter: State holds a ConcurrentHashMap<Thread, ScratchBuffer>,
grown as needed, pruned for dead threads, and closed by destructorDispatch. Fixes
Sonar S5164 without a suppression.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dfa1
dfa1 merged commit 281e1d8 into main Nov 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant