nativelink icon indicating copy to clipboard operation
nativelink copied to clipboard

Span tracing

Open adam-singer opened this issue 1 year ago • 2 comments

Description

Adding feature to enable/disable builds of nativelink to include trace spans.

Trace spans can be use for instrumenting historical call paths of the tokio workers. Implementation provided shunts enabling/disabling at the cfg/features flags level. Enabling this feature would have performance runtime impact and should be used in debugging/introspection scenarios. Applying the instrumentation updates the source tree and not expected to be checked in (atm). The span format uses chrome tracing json and can be viewed in chrome://tracing (or https://ui.perfetto.dev/). Trace snapshots are collected upon sever exit.

Output traces upon server exit are dumped in the cwd of the nativelink bin in the format trace-*.json

Example

# Apply instrumentation
./tools/patch_tracing.sh fix
# Build/Run
RUST_LOG=INFO cargo --config 'build.rustflags=["--cfg", "tokio_unstable", "--cfg", "enable_tracing"]' run --features enable_tokio_console,enable_tracing -- nativelink-config/examples/basic_cas.json
# Unapply instrumentation
./tools/patch_tracing.sh strip
Screenshot 2024-01-03 at 6 24 14 PM

Open Questions

Should trace snapshots be collected upon server exit, client requests or external signal to admin ports?

Should clippy-tracing be a preinstalled expectation or configured/added in nix?

Should we checkin the tracing macro and create linting that auto lints (fix) the source tree when instrumentation is missing?

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

How Has This Been Tested?

Please also list any relevant details for your test configuration

Checklist

  • [ ] Updated documentation if needed
  • [ ] Tests added/amended
  • [ ] bazel test //... passes locally
  • [ ] PR is contained in a single commit, using git amend see some docs

This change is Reviewable

adam-singer avatar Jan 04 '24 02:01 adam-singer

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nativelink-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 9:14pm

vercel[bot] avatar Jan 10 '24 07:01 vercel[bot]

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 15 '24 21:05 CLAassistant