-
Notifications
You must be signed in to change notification settings - Fork 5k
Revise perfjitdump #229
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
Revise perfjitdump #229
Conversation
Remove unnecessary fsync() call Use writev() instead of write() to reduce OS calls Handle partial write cases
Thanks @lpereira |
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.
LGTM, thank you!
@@ -136,7 +136,7 @@ struct PerfJitDumpState | |||
codeIndex(0) | |||
{} | |||
|
|||
bool enabled; | |||
volatile bool enabled; |
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.
Use of volatile
in C++ always make me uneasy that it's actually hiding something else. I haven't read the code for PerfJitDumpState
yet, but what's the reason to qualify enabled
as volatile here?
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.
It is a variable that is expected to be written by another thread during Finish
.
Before we lock the mutex, we read enabled
. After locking I want to make sure enabled
is read again in case Finish
disabled it. I marked it as volatile to prevent the optimizer from using the value it had initially read. Given that the locking is a function call it might not be needed, but I don't fully understand the nuances of the C++ optimization rules.
Remove unnecessary fsync() call
Use writev() instead of write() to reduce OS calls
Handle partial write cases
Fixes dotnet/coreclr#27912 (aka #13812)