Skip to content

Miscellaneous fixes for tracing #4489

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Stypox
Copy link
Contributor

@Stypox Stypox commented Jul 22, 2025

This PR contains a few misc fixes for the tracing code that was recently added:

@rustbot ready

@rustbot
Copy link
Collaborator

rustbot commented Jul 22, 2025

Thank you for contributing to Miri!
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Jul 22, 2025
match self.trace_style {
TraceStyle::Threaded => {
if span.fields().field("tracing_separate_thread").is_some() {
// assign an independent "id" to spans with argument "tracing_separate_thread",
// so they appear a separate trace line in trace visualization tools, see
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
Some(span.id().into_u64())
Some(span.id().into_u64() as i64)
Copy link
Member

Choose a reason for hiding this comment

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

This might wrap around -- isn't that a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that's by design, I tested and Perfetto accepts 64-bit 2s complement signed integers (i.e. from -2^63 to 2^63-1), so wrapping around is intended

Copy link
Member

Choose a reason for hiding this comment

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

Then please call cast_signed instead, and ideally add a comment saying that perfetto is fine with negative numbers that for in an i64, but not fine with numbers above i64::MAX. Bare as casts are always sus.

Copy link
Member

Choose a reason for hiding this comment

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

Then please call cast_signed instead

This is still unresolved

@Stypox Stypox force-pushed the misc-tracing-fixes branch from a8e42fa to 58d8b16 Compare July 23, 2025 13:16
@Stypox
Copy link
Contributor Author

Stypox commented Jul 23, 2025

I improved the markdown comment and also included info about why we cast u64 to i64 with wraparound

Stypox added 3 commits July 23, 2025 16:42
Perfetto gives an error if an id does not fit in an 64-bit signed integer in 2's complement.
@Stypox Stypox force-pushed the misc-tracing-fixes branch from 58d8b16 to 0a8a3a1 Compare July 23, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants