-
Notifications
You must be signed in to change notification settings - Fork 937
Fix random failures from Live profiling #1376
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
Fix random failures from Live profiling #1376
Conversation
Could you explain why the test was failing and what is the idea of the fix? |
Basically from what I could tell in some cases the VM dies without any proper LIVE sampling by the profiler The idea is to keep some allocated memory that is never cleared to garantee live reference Also we call System.gc to update the live reference list in the profiler |
OK, sounds good. I'd only make the amount of allocated memory limited, to ensure the app never throws
In what sense "update"? Why is it needed? |
sure, I will limit the number of saved allocations
GC would cause the following method to be called
This in turn will cause the next information stored in |
So what happens if |
In normal applications GC would be called naturally (we want a GC to happen as to update live reference list in profiler) for this short lived test we want to give the best chances to get the latest data so I manually call System.gc |
This test allocates 64KB arrays repeatedly in a loop, this is supposed to cause "natural" GC. |
That's a good point, What's confirmed that in some cases we never see LIVE events which could mean that one of the following things happen
I will need to check which is which on this case |
Async-profiler allocation profiling uses sampling, it does not handle each individual allocation by design. The same is true for As to |
Thanks for the clarification, In either case the The main problem is after a GC call it's possible that old LIVE references previously collected would have died & the profiler don't get sampling to record the new LIVE references which is fine The static array should solve that for this as we will always have references that would never be freed |
System.gc removed here a01fdc5 |
|
||
private static volatile Object sink; | ||
private static int count = 0; | ||
private static final List<byte[]> rooter = new ArrayList<>(); |
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 word "rooter" means something else. Maybe rename it to root
or holder
?
Description
Fixes random test failures that happens for live profiling
https://github.com/async-profiler/async-profiler/actions/runs/16172680977/job/45650081518
Related issues
N/A
Motivation and context
solve flakey test
How has this been tested?
make test
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.