-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: reduce MDT compaction heap pressure in BitCaskDiskMap and ExternalSpillableMap #19085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -315,6 +315,22 @@ public Stream<R> valueStream() { | |
| return Stream.concat(inMemoryMap.values().stream(), diskBasedMap.valueStream()); | ||
| } | ||
|
|
||
| /** | ||
| * Returns a lazy stream over all keys in this map (in-memory + spilled). | ||
| * | ||
| * Unlike {@link #keySet()}, this method does NOT allocate a new {@link java.util.HashSet} copying | ||
| * all keys. When the map has spilled ({@code diskBasedMap != null}), {@link #keySet()} must | ||
| * materialise a full copy to combine both key sets into a single {@link java.util.Set}. Callers | ||
| * that only need to iterate keys once (e.g. to seed a {@link java.util.PriorityQueue}) should | ||
| * prefer this method to avoid the transient per-task heap spike (ENG-43078). | ||
| */ | ||
| public Stream<T> keyStream() { | ||
| if (diskBasedMap == null) { | ||
| return inMemoryMap.keySet().stream(); | ||
| } | ||
| return Stream.concat(inMemoryMap.keySet().stream(), diskBasedMap.keySet().stream()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 When the map has spilled, |
||
| } | ||
|
|
||
| @Override | ||
| public Set<Entry<T, R>> entrySet() { | ||
| if (diskBasedMap == null) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 nit:
.sequential()is a no-op here —ArrayList.stream()already returns a sequential stream. Could you drop it? It may leave a future reader wondering whether parallelism was a concern and whether the stream might become parallel.