-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Flush oldest sink when total rows in all sinks exceeds maxRowsInMemory #2459
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
b98ed37
7a0f37d
afe5444
6c87e6c
07cc583
782cb89
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 |
|---|---|---|
|
|
@@ -325,6 +325,7 @@ public Plumber findPlumber( | |
|
|
||
| new RealtimeTuningConfig( | ||
| 1, | ||
| null, | ||
| new Period("PT10M"), | ||
| null, | ||
| null, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ | |
| public class RealtimeTuningConfig implements TuningConfig, AppenderatorConfig | ||
| { | ||
| private static final int defaultMaxRowsInMemory = 75000; | ||
| private static final int defaultMaxOccupationInMemory = 64 << 20; | ||
|
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. Any reason for this default? It seems small, perhaps default it to 1/4 of the heap size instead.
Contributor
Author
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. I also thought "estimatedOccupation" is basically underestimated value. It's hard to estimate memory usage in java inherently and can different from environments like version, os, etc. "If it cannot be exact, let it have some conservative value by default and make it configurable by users", that I though. |
||
| private static final Period defaultIntermediatePersistPeriod = new Period("PT10M"); | ||
| private static final Period defaultWindowPeriod = new Period("PT10M"); | ||
| private static final VersioningPolicy defaultVersioningPolicy = new IntervalStartVersioningPolicy(); | ||
|
|
@@ -61,6 +62,7 @@ public static RealtimeTuningConfig makeDefaultTuningConfig(final File basePersis | |
| { | ||
| return new RealtimeTuningConfig( | ||
| defaultMaxRowsInMemory, | ||
| defaultMaxOccupationInMemory, | ||
| defaultIntermediatePersistPeriod, | ||
| defaultWindowPeriod, | ||
| basePersistDirectory == null ? createNewBasePersistDirectory() : basePersistDirectory, | ||
|
|
@@ -78,6 +80,7 @@ public static RealtimeTuningConfig makeDefaultTuningConfig(final File basePersis | |
| } | ||
|
|
||
| private final int maxRowsInMemory; | ||
| private final int maxOccupationInMemory; | ||
| private final Period intermediatePersistPeriod; | ||
| private final Period windowPeriod; | ||
| private final File basePersistDirectory; | ||
|
|
@@ -95,6 +98,7 @@ public static RealtimeTuningConfig makeDefaultTuningConfig(final File basePersis | |
| @JsonCreator | ||
| public RealtimeTuningConfig( | ||
| @JsonProperty("maxRowsInMemory") Integer maxRowsInMemory, | ||
| @JsonProperty("maxOccupationInMemory") Integer maxOccupationInMemory, | ||
| @JsonProperty("intermediatePersistPeriod") Period intermediatePersistPeriod, | ||
| @JsonProperty("windowPeriod") Period windowPeriod, | ||
| @JsonProperty("basePersistDirectory") File basePersistDirectory, | ||
|
|
@@ -111,6 +115,7 @@ public RealtimeTuningConfig( | |
| ) | ||
| { | ||
| this.maxRowsInMemory = maxRowsInMemory == null ? defaultMaxRowsInMemory : maxRowsInMemory; | ||
| this.maxOccupationInMemory = maxOccupationInMemory == null ? defaultMaxOccupationInMemory : maxOccupationInMemory; | ||
| this.intermediatePersistPeriod = intermediatePersistPeriod == null | ||
| ? defaultIntermediatePersistPeriod | ||
| : intermediatePersistPeriod; | ||
|
|
@@ -134,6 +139,7 @@ public RealtimeTuningConfig( | |
| ? defaultHandoffConditionTimeout | ||
| : handoffConditionTimeout; | ||
| Preconditions.checkArgument(this.handoffConditionTimeout >= 0, "handoffConditionTimeout must be >= 0"); | ||
| Preconditions.checkArgument(this.maxRowsInMemory > 0, "maxRowsInMemory must be > 0"); | ||
| } | ||
|
|
||
| @JsonProperty | ||
|
|
@@ -142,6 +148,12 @@ public int getMaxRowsInMemory() | |
| return maxRowsInMemory; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public int getMaxOccupationInMemory() | ||
| { | ||
| return maxOccupationInMemory; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public Period getIntermediatePersistPeriod() | ||
| { | ||
|
|
@@ -224,6 +236,7 @@ public RealtimeTuningConfig withVersioningPolicy(VersioningPolicy policy) | |
| { | ||
| return new RealtimeTuningConfig( | ||
| maxRowsInMemory, | ||
| maxOccupationInMemory, | ||
| intermediatePersistPeriod, | ||
| windowPeriod, | ||
| basePersistDirectory, | ||
|
|
@@ -244,6 +257,7 @@ public RealtimeTuningConfig withBasePersistDirectory(File dir) | |
| { | ||
| return new RealtimeTuningConfig( | ||
| maxRowsInMemory, | ||
| maxOccupationInMemory, | ||
| intermediatePersistPeriod, | ||
| windowPeriod, | ||
| dir, | ||
|
|
||
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 assume this is meant to check the heap occupation. This is a great change, it's not awesomely accurate but it's probably better than guessing at maxRowsInMemory.
It'd be good to have a comment about the ways in which the estimate can be inaccurate:
Also, the heap footprint is really different depending on which IncrementalIndex implementation is being used, so maybe it's best to have IncrementalIndex do
return 0and move this impl to OnheapIncrementalIndex. I think the other incremental index impls would never have this method called (because Sink always uses OnheapIncrementalIndex).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.
May also be nice to add in estimation for the facts part of the dimensions.
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 agree on all of the your comments. It's just for estimation which can be relative (if it's half of real occupation, we just can set it as a half) and advisory at best rather than exact.