Skip to content

Add an option so perf jit dump can optionally use TSC for timestamps. #110809

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

Closed
Kuinox opened this issue Dec 18, 2024 · 9 comments · Fixed by #111359
Closed

Add an option so perf jit dump can optionally use TSC for timestamps. #110809

Kuinox opened this issue Dec 18, 2024 · 9 comments · Fixed by #111359
Labels
area-Diagnostics-coreclr enhancement Product code improvement that does NOT require public API changes/additions in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@Kuinox
Copy link
Contributor

Kuinox commented Dec 18, 2024

I'm trying to make perf with Intel PT works with RyuJIT.
It currently doesn't work because Intel PT use TSC as a timestamp, and RyuJIT uses the monotonic clock for the dump timestamp.

The change would read the environment variable flag JITDUMP_USE_ARCH_TIMESTAMP, and when this flag is true, change the behavior of GetTimeStampNS to use __rdtsc, and also set the file header flag JITDUMP_FLAGS_ARCH_TIMESTAMP

I'm open to do the contribution, but I have next to no experience with C++.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 18, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 18, 2024

This comment has been minimized.

@Kuinox Kuinox changed the title Add an option so perf jit dump can use TSC for timestamps. Add an option so perf jit dump can optionally use TSC for timestamps. Dec 18, 2024
@EgorBo EgorBo added area-Diagnostics-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Dec 18, 2024
Copy link
Contributor

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

@tommcdon tommcdon added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-Diagnostics-coreclr labels Dec 20, 2024

This comment has been minimized.

@jkotas
Copy link
Member

jkotas commented Dec 20, 2024

This issue about Linux perf tool support. Historically, this fell into area-Diagnostics (for example, check dotnet/coreclr#26897, #229, #99986, ...). @tommcdon Is it intentional that we want Linux perf tool support to be tracked under CodeGen now?

@tommcdon tommcdon added area-Diagnostics-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Dec 20, 2024

This comment has been minimized.

@tommcdon
Copy link
Member

This issue about Linux perf tool support. Historically, this fell into area-Diagnostics (for example, check dotnet/coreclr#26897, #229, #99986, ...). @tommcdon Is it intentional that we want Linux perf tool support to be tracked under CodeGen now?

Thanks Jan! Moving to dotnet-diagnostics-coreclr - I had originally read this issue as being an RyuJIT request

@tommcdon tommcdon added this to the 10.0.0 milestone Dec 20, 2024
@tommcdon tommcdon added enhancement Product code improvement that does NOT require public API changes/additions and removed untriaged New issue has not been triaged by the area owner labels Dec 20, 2024
@Kuinox
Copy link
Contributor Author

Kuinox commented Dec 21, 2024

Since I will try to implement this, can I get some guidance if there is a specific method to call to get __rdtsc there, what to do when not running on AMD64 (compile flags for AMD64 ?)

@jkotas
Copy link
Member

jkotas commented Dec 21, 2024

there is a specific method to call to get __rdtsc there

You can #include <x86intrin.h> that defines __rdtsc() method. Alternatively, you can implement it using inline assembly. There are plenty of examples in other projects that implement suport for JITDUMP_FLAGS_ARCH_TIMESTAMP: https://github.com/search?q=JITDUMP_FLAGS_ARCH_TIMESTAMP&type=code

what to do when not running on AMD64 (compile flags for AMD64 ?)

We use HOST_AMD64 define in situations like this, e.g. #if defined(HOST_AMD64).

@Kuinox
Copy link
Contributor Author

Kuinox commented Dec 21, 2024

You can #include <x86intrin.h> that defines

This question was also if I needed to use some helper method like what GetTimestampNs uses.

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Jan 13, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Diagnostics-coreclr enhancement Product code improvement that does NOT require public API changes/additions in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants