-
Notifications
You must be signed in to change notification settings - Fork 3.8k
GCInspector should use different thresholds on GC events #4433
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
Open
Yukei7
wants to merge
2
commits into
apache:trunk
Choose a base branch
from
Yukei7:c20980
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+220
−26
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -287,23 +287,53 @@ public void handleNotification(final Notification notification, final Object han | |
| if (state.compareAndSet(prev, new State(duration, bytes, prev))) | ||
| break; | ||
| } | ||
|
|
||
| if (getGcWarnThresholdInMs() != 0 && duration > getGcWarnThresholdInMs()) | ||
| logger.warn(sb.toString()); | ||
| else if (duration > getGcLogThresholdInMs()) | ||
| logger.info(sb.toString()); | ||
| else if (logger.isTraceEnabled()) | ||
| logger.trace(sb.toString()); | ||
|
|
||
| if (duration > this.getStatusThresholdInMs()) | ||
| StatusLogger.log(); | ||
| if (isConcurrentPhase(info.getGcCause(), info.getGcName())) | ||
| { | ||
| if (getGcWarnThresholdInMs() != 0 && duration > getGcWarnThresholdInMs()) | ||
|
||
| logger.warn(sb.toString()); | ||
| else if (duration > getGcLogThresholdInMs()) | ||
| logger.info(sb.toString()); | ||
| else if (logger.isTraceEnabled()) | ||
| logger.trace(sb.toString()); | ||
| // TODO: trigger StatusLogger if concurrent phases take too long? | ||
| } | ||
| else | ||
| { | ||
| if (getGcConcurrentPhaseWarnThresholdInMs() != 0 && duration > getGcConcurrentPhaseWarnThresholdInMs()) | ||
| logger.warn(sb.toString()); | ||
| else if (duration > getGcConcurrentPhaseLogThresholdInMs()) | ||
| logger.info(sb.toString()); | ||
| else if (logger.isTraceEnabled()) | ||
| logger.trace(sb.toString()); | ||
| if (duration > this.getStatusThresholdInMs()) | ||
| StatusLogger.log(); | ||
| } | ||
|
|
||
| // if we just finished an old gen collection and we're still using a lot of memory, try to reduce the pressure | ||
| if (gcState.assumeGCIsOldGen) | ||
| LifecycleTransaction.rescheduleFailedDeletions(); | ||
| } | ||
| } | ||
|
|
||
| static boolean isConcurrentPhase(String cause, String name) { | ||
| // Mostly taken from: https://github.com/Netflix/spectator/blob/v1.7.x/spectator-ext-gc/src/main/java/com/netflix/spectator/gc/GcLogger.java | ||
| // So far the only indicator known is that the cause will be reported as "No GC" | ||
| // when using CMS. | ||
| // | ||
| // For ZGC, behavior was changed in JDK17: https://bugs.openjdk.java.net/browse/JDK-8265136 | ||
| // For ZGC in older versions, there is no way to accurately get the amount of time | ||
| // in STW pauses. | ||
| // | ||
| // For G1, a new bean is added in JDK20 to indicate time spent in concurrent phases: | ||
| // https://bugs.openjdk.org/browse/JDK-8297247 | ||
|
|
||
| return "No GC".equals(cause) // CMS | ||
| || "G1 Concurrent GC".equals(name) // G1 in JDK20+ | ||
| || name.endsWith(" Cycles"); // Shenandoah, ZGC | ||
| } | ||
|
|
||
|
|
||
| public State getTotalSinceLastCheck() | ||
| { | ||
| return state.getAndSet(new State()); | ||
|
|
@@ -407,6 +437,40 @@ public void setGcLogThresholdInMs(long threshold) | |
| DatabaseDescriptor.setGCLogThreshold((int) threshold); | ||
| } | ||
|
|
||
| public int getGcConcurrentPhaseWarnThresholdInMs() | ||
| { | ||
| return DatabaseDescriptor.getGCConcurrentPhaseWarnThreshold(); | ||
| } | ||
|
|
||
| public void setGcConcurrentPhaseWarnThresholdInMs(int threshold) | ||
| { | ||
| long gcConcurrentPhaseLogThresholdInMs = getGcConcurrentPhaseLogThresholdInMs(); | ||
| if (threshold < 0) | ||
| throw new IllegalArgumentException("Threshold must be greater than or equal to 0"); | ||
| if (threshold != 0 && threshold <= gcConcurrentPhaseLogThresholdInMs) | ||
| throw new IllegalArgumentException("Threshold must be greater than gcConcurrentPhaseLogThresholdInMs which is currently " | ||
| + gcConcurrentPhaseLogThresholdInMs); | ||
| DatabaseDescriptor.setGCConcurrentPhaseWarnThreshold(threshold); | ||
| } | ||
|
|
||
| public int getGcConcurrentPhaseLogThresholdInMs() | ||
| { | ||
| return DatabaseDescriptor.getGCConcurrentPhaseLogThreshold(); | ||
| } | ||
|
|
||
| public void setGcConcurrentPhaseLogThresholdInMs(int threshold) | ||
| { | ||
| if (threshold <= 0) | ||
| throw new IllegalArgumentException("Threshold must be greater than 0"); | ||
|
|
||
| long gcConcurrentPhaseWarnThresholdInMs = getGcConcurrentPhaseWarnThresholdInMs(); | ||
| if (gcConcurrentPhaseWarnThresholdInMs != 0 && threshold > gcConcurrentPhaseWarnThresholdInMs) | ||
| throw new IllegalArgumentException("Threshold must be less than gcConcurrentPhaseWarnThresholdInMs which is currently " | ||
| + gcConcurrentPhaseWarnThresholdInMs); | ||
|
|
||
| DatabaseDescriptor.setGCConcurrentPhaseLogThreshold(threshold); | ||
| } | ||
|
|
||
| public long getGcLogThresholdInMs() | ||
| { | ||
| return DatabaseDescriptor.getGCLogThreshold(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
the value (200) in the description does not match the value in the commented value lower (1000)
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.
updated - thanks for catching this!