-
Notifications
You must be signed in to change notification settings - Fork 916
Reset CallTraceStorage counters before reporting live objects. #1009
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e84d12a
Reset CallTraceStorage counters before reporting live objects.
krk eced671
Merge remote-tracking branch 'upstream/master' into lives
krk 017f171
Do not reset samples while jfr is active.
krk 29c3c02
address comments
krk 0d1f56c
address comments
krk b0f7a13
address comments
krk b907d69
address comments
krk f0a6417
spaces and comments
krk 1825ce0
Removed extra whitespace changes
apangin 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 |
---|---|---|
|
@@ -25,6 +25,12 @@ public static void isGreater(double value, double threshold, String message) { | |
} | ||
} | ||
|
||
public static void isGreaterOrEqual(double value, double threshold) { | ||
if (value < threshold) { | ||
throw new AssertionError("Expected " + value + " >= " + threshold); | ||
} | ||
} | ||
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. For assertions consistency, let's add this after #1027. 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. These are used in the current commit, happy to replace them with #1027 when it is merged. |
||
|
||
public static void isLess(double value, double threshold) { | ||
isLess(value, threshold, null); | ||
} | ||
|
@@ -38,4 +44,10 @@ public static void isLess(double value, double threshold, String message) { | |
"Expected " + value + " < " + threshold + (message != null ? (": " + message) : "")); | ||
} | ||
} | ||
|
||
public static void isLessOrEqual(double value, double threshold) { | ||
if (value > threshold) { | ||
throw new AssertionError("Expected " + value + " <= " + threshold); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright The async-profiler authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package test.alloc; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class RandomBlockRetainer { | ||
public static void main(String[] args) throws Exception { | ||
double keepChance = 0.5; | ||
if (args.length > 0) { | ||
try { | ||
keepChance = Double.parseDouble(args[0]); | ||
} catch (NumberFormatException e) { | ||
System.err.println("Invalid keepChance value. Using default value of 0.5."); | ||
} | ||
} | ||
|
||
// Set up a list to hold large objects and keep them in memory. | ||
List<byte[]> rooter = new ArrayList<>(); | ||
|
||
final int TOTAL_BLOCKS = 500; // Has to be less than LiveRefs::MAX_REFS for testing purposes. | ||
final int BLOCK_SIZE = 100 * 1000; | ||
|
||
for (int i = 0; i < TOTAL_BLOCKS; i++) { | ||
byte[] block = i % 2 == 0 ? alloc1(BLOCK_SIZE) : alloc2(BLOCK_SIZE); | ||
|
||
if (Math.random() <= keepChance) { | ||
// Keep a reference to prevent the block from being garbage collected | ||
rooter.add(block); | ||
} | ||
} | ||
|
||
System.gc(); | ||
} | ||
|
||
private static byte[] alloc1(int size) { | ||
return new byte[size]; | ||
} | ||
|
||
private static byte[] alloc2(int size) { | ||
return new byte[size]; | ||
} | ||
} |
Oops, something went wrong.
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.
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.
Don't we need to reset
s.samples
too?Check that flame graph is generated correctly both with and without
--total
option.