Skip to content

Conversation

@jschwe
Copy link
Member

@jschwe jschwe commented Oct 25, 2025

There are multiple motivating factors for this change:

  1. tracing-rs can and is commonly used for structured logging, to gain understanding in what is happening in concurrent code. We would like to attempt to make a distinction of the performance tracing related usage and the logging related usage.
  2. This reduces boilerplate code. We don't have to feature guard every span anymore, since the macro will do it for us.
  3. This makes it easier to add multiple options for the trace backend (i.e. exchanging tracing-rs for hitrace on OpenHarmony or System Tracing in Android), or something entirely custom.
  4. This makes it easier to add further compile-time options to control the amount of tracing. E.g. a future PR could add options to enable tracing based on environment variables set at compile time. Tracing adds runtime overhead, even if the runtime switch is disabled, so having more fine-grained options to partially enabled tracing could be useful.

Testing: Tested manually by building with and without the tracing feature. In CI we also build with the tracing feature in the HarmonyOS build. We don't have any automated tests for the correctness / presence of the traced entries.

@mrobinson
Copy link
Member

CC @delan who I think had some ideas for moving away from tracing for profiling, though I could be misremembering.

#[cfg(feature = "tracing")]
#[allow(dead_code)]
span: tracing::span::EnteredSpan,
span: profile_traits::servo_tracing::span::EnteredSpan,
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess this is the part that is actually interesting. We could avoid the feature flag here, by exposing the Span type and friends in profile_traits. The actual implementation of the types could depend on additional feature flags (e.g. tracing-rs enables the tracing-rs backend, hitrace enables the hitrace backend, nothing enables the dummy backend as a fallback. Multiple feature enabled would result in a compile time error, or we decide on a priority)

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this part again, and leave handling this use-case to a follow-up

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
@jschwe jschwe force-pushed the jschwender/tracing_macro_abstract branch from 2555db2 to 2d6af3b Compare November 18, 2025 09:14
@jschwe jschwe marked this pull request as ready for review November 18, 2025 09:15
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 18, 2025
@jschwe
Copy link
Member Author

jschwe commented Nov 18, 2025

Rebased the changes from last time. Probably best to land this as-is, and iterate over the remaining tracing usages in a follow-up.

@jschwe jschwe added this pull request to the merge queue Nov 18, 2025
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 18, 2025
Merged via the queue into servo:main with commit 2028dab Nov 18, 2025
35 checks passed
@jschwe jschwe deleted the jschwender/tracing_macro_abstract branch November 18, 2025 11:35
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants