GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix incorrect exit code for asprof when running in collect mode by Baraa-Hasheesh · Pull Request #1623 · async-profiler/async-profiler Conversation
Contributor
DescriptionThis change tackles one of the race conditions described in #1622 Being the race condition of what will execute first, the If In this change, an internal flag is passed from Related issuesMotivation and contextasprof shouldn't have a non zero exit code from VMDeath How has this been tested?manual testing By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
apangin
reviewed
Collaborator
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. No "secret" options please.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
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. The problem I kept hitting, is that profiler has different behavior depending on various condition, I wanted to keep the behaviors untouched as is, For example, the following won't generate a log while, this will generate a log so a "secret" made sense to not effect existing behaviors
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
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.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
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've updated my approach to be determined on the usage, If the user starts the asprof with a file, then it's fine for the stop call to fail on termination & that failed stop can be considered a success (the VMDeath would have done the dump for the user) So the user can address this race in any custom script by providing the output file in both start & stop as the asprof collect is currently doing ee54ad2
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
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. OK, stopping profiler in
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
|
||
| static ProfilingWindow profiling_window; | ||
|
|
||
| static const char* _start_file = NULL; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary. If _start_file comes from _global_args, then you can access it via _global_args. But if it comes from elsewhere, the pointer will be invalid.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
that make sense
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Error Profiler::dump(Writer& out, Arguments& args) { | ||
| MutexLocker ml(_state_lock); | ||
| if (_state != IDLE && _state != RUNNING) { | ||
| if (_state == TERMINATED && _start_file != NULL && args.rawFile() != NULL && strcmp(_start_file, args.rawFile()) == 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is a bit better than _collect, but is still a hack. I was thinking of something simpler, like always returning Error::OK for stop command if we are in TERMINATED. Although this is not fully accurate, I can't imagine a case when this is a real problem.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Alright, what about this hack:
if (_state == TERMINATED && args.hasTemporaryLog()) {
return Error::OK;
}
The effect is the same as in your first revision, just with less code changes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
like always returning Error::OK for stop command if we are in TERMINATED
The real problematic part is the dump command not the stop & the dump will fail if profiler is terminated (Not safe to access JNI & JVMTI)
IMO if the output selected by the user isn't dumped, then that should be considered a failure, what are you thoughts on this @apangin
From this perspective the only way for the profiler to dump it correclty, is for the user to provide the output file on the start command, hence my hack
Alright, what about this hack:
if (_state == TERMINATED && args.hasTemporaryLog()) {
return Error::OK;
}
The effect is the same as in your first revision, just with less code changes.
This will also mark normal stops as a success even if the profiler didn't really write the profiles, which is wrong
asprof start -e cpu 1234
sleep 10
asprof stop -f out.html 1234 <--- this hit the race condition & unable to generate the out.html
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
OK, agreed - let's proceed with the file trick as I don't see a simple way to solve this cleanly without redesigning the entire protocol.
A good news is that it will be a tiny local change: all you need is to compare args._file to _global_args._file.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
handled here 2c1c53d
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.