Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JIT: remove dependence on GetThreadCycles #114290

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 3 commits into from
Apr 7, 2025

Conversation

AndyAyersMS
Copy link
Member

and hence on pal-provided QueryThreadCycleTime.

Use QueryPerformanceCounter/Frequency instead. This should be good enough for this feature (considering it exists only under DEBUG).

Fixes #105472

and hence on pal-provided QueryThreadCycleTime.

Use QueryPerformanceCounter/Frequency instead. This should be good enough
for this feature (considering it exists only under DEBUG).

Fixes dotnet#105472
@Copilot Copilot AI review requested due to automatic review settings April 5, 2025 00:38
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 5, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

bool b = CycleTimer::GetThreadCyclesS(&m_compCyclesAtEndOfInlining);
if (!b)
LARGE_INTEGER lpCycles;
BOOL result = QueryPerformanceCounter(&lpCycles);
Copy link
Preview

Copilot AI Apr 5, 2025

Choose a reason for hiding this comment

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

If QueryPerformanceCounter fails (i.e. result is not TRUE), there is no fallback mechanism (e.g. using GetTickCount as before), which may lead to m_compCyclesAtEndOfInlining remaining uninitialized. Consider adding a fallback to ensure a value is recorded.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

This API is documented to never fail, so we could just ignore the result.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like the pal version still might fail. Though perhaps this never happens in practice. I'll leave this as is for now.

{
return; // We don't have a thread cycle counter.
if ((int64_t)lpCycles.QuadPart > m_compCyclesAtEndOfInlining)
Copy link
Preview

Copilot AI Apr 5, 2025

Choose a reason for hiding this comment

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

The current logic only updates m_compCycles when the new performance counter value exceeds m_compCyclesAtEndOfInlining. It may be beneficial to explicitly handle or log cases where this condition fails to avoid inadvertently reporting a zero elapsed time.

Copilot uses AI. Check for mistakes.

@AndyAyersMS
Copy link
Member Author

@dotnet/jit-contrib PTAL

Arguably we should go farther and remove the uses from SPMI too, and then the PAL support...
Also references to SQM in jit comments are no longer relevant.

@AndyAyersMS AndyAyersMS merged commit 68a3c1e into dotnet:main Apr 7, 2025
111 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
4 participants