Skip to content
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

WIP_Update to Windows Profiler #20687

Closed
wants to merge 7 commits into from

Conversation

batesl87
Copy link

#9224
I've made two changes to the Profiler on Windows.

  • Randomised the time interval between samples. The interval is multiplied by a random number between 0 and 2.
  • Utilised QPC to achieve microsecond sleep intervals. The use of Sleep(0) is key as it offers the rest of the time slice allocated to the Profiler thread to other threads of the same priority.

@timholy

Added high precision sleep
Applied random factor between 0 and 2 to timeout
Moved StartingTime to not include rand()
TIMECAPS tc;
if (MMSYSERR_NOERROR!=timeGetDevCaps(&tc, sizeof(tc))) {
fputs("failed to get timer resolution",stderr);
hBtThread = 0;
return 0;
}

//Precision timer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use multiples of 4 spaces for indentation rather than tabs for consistency with the rest of the repository.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. I've recommited.

QueryPerformanceCounter(&StartingTime);
int time_elapsed = 0;
while (time_elapsed ==0)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's trailing whitespace on this line, which is what's causing the check to fail

@kshyatt kshyatt added the system:windows Affects only Windows label Feb 20, 2017
@tkelman
Copy link
Contributor

tkelman commented Feb 21, 2017

If we're randomizing the profile interval, we should probably do that across all platforms. Could we split the randomization from the windows-specific timer change into separate PR's?

//calculate start time for high precision sleep
QueryPerformanceCounter(&StartingTime);
int time_elapsed = 0;
while (time_elapsed ==0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor, but would look a little nicer with spaces on both sides of the ==, not just on the left

}
else
{
//if time has not elasped offer up processor to another thread
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elapsed

@tkelman
Copy link
Contributor

tkelman commented Feb 23, 2017

for reference/reviewer selection, looks like this code was originally authored in 8247ac7

@tkelman
Copy link
Contributor

tkelman commented Mar 1, 2017

is this still WIP, or RFC?

@batesl87
Copy link
Author

batesl87 commented Mar 2, 2017

It's still WIP. Small profiler intervals can cause julia to crash (see below). I haven't had a chance to chase it down, but could this be due to the StackWalk64 not being thread-safe as mentioned in #2597 @vtjnash

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x7ff8ed36bc62 -- RtlVirtualUnwind at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
while loading no file, in expression starting on line 0

@vtjnash
Copy link
Member

vtjnash commented Oct 27, 2020

There's still interest in #9224, but we should do it on all platforms. We don't want to busy wait (like this PR), since that can skew the results even more significantly however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:windows Affects only Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants