-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Improvement] DataSegment intern improvement (reduce 60% memory consume on coordinator) #8165
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
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 |
|---|---|---|
|
|
@@ -76,9 +76,22 @@ public static class PruneLoadSpecHolder | |
| @Inject(optional = true) @PruneLoadSpec boolean pruneLoadSpec = false; | ||
| } | ||
|
|
||
| public static DataSegment intern(DataSegment dataSegment, boolean updateLoadSpec) | ||
| { | ||
| DataSegment result = DATA_SEGMENT_INTERNER.intern(dataSegment); | ||
| if (updateLoadSpec) { | ||
| result.dimensions = dataSegment.dimensions; | ||
| result.metrics = dataSegment.metrics; | ||
| result.loadSpec = dataSegment.loadSpec; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
|
|
||
| private static final Interner<String> STRING_INTERNER = Interners.newWeakInterner(); | ||
| private static final Interner<List<String>> DIMENSIONS_INTERNER = Interners.newWeakInterner(); | ||
| private static final Interner<List<String>> METRICS_INTERNER = Interners.newWeakInterner(); | ||
| private static final Interner<DataSegment> DATA_SEGMENT_INTERNER = Interners.newWeakInterner(); | ||
|
Member
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. This humongous Map with millions of weak references would be a problem for GC in itself: see #6357 for context. You should adopt the design with |
||
| private static final Map<String, Object> PRUNED_LOAD_SPEC = ImmutableMap.of( | ||
| "load spec is pruned, because it's not needed on Brokers, but eats a lot of heap space", | ||
| "" | ||
|
|
@@ -87,9 +100,9 @@ public static class PruneLoadSpecHolder | |
| private final Integer binaryVersion; | ||
| private final SegmentId id; | ||
| @Nullable | ||
| private final Map<String, Object> loadSpec; | ||
| private final List<String> dimensions; | ||
| private final List<String> metrics; | ||
| private volatile Map<String, Object> loadSpec; | ||
|
Member
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. Making |
||
| private volatile List<String> dimensions; | ||
| private volatile List<String> metrics; | ||
| private final ShardSpec shardSpec; | ||
| private final long size; | ||
|
|
||
|
|
||
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.
I think
DataSegmentshouldn't become mutable. However, it would be nice if you would solve this problem in this PR: #6358.