3 ms·
Funny timing—I tried optimizing the Otel Go SDK a few weeks ago (https://github.com/open-telemetry/opentelemetry-go/issues/6721 https://github.com/open-telemetr
by sa46 1y ago
Funny timing—I tried optimizing the Otel Go SDK a few weeks ago (https://github.com/open-telemetry/opentelemetry-go/issues/6721 https://github.com/open-telemetry/opentelemetry-go/issues/67...).
I suspect you could make the tracing SDK 2x faster with some cleverness. The main tricks are:
- Use a faster time.Now(). Go does a fair bit of work to convert to the Go epoch.
- Use atomics instead of a mutex. I sent a PR, but the reviewer caught correctness issues. Atomics are subtle and tricky.
- Directly marshal protos instead of reflection with a hand-rolled library or with https://github.com/VictoriaMetrics/easyproto https://github.com/VictoriaMetrics/easyproto.
The gold standard is how TiDB implemented tracing (https://www.pingcap.com/blog/how-we-trace-a-kv-database-with-less-than-5-percent-performance-impact/ https://www.pingcap.com/blog/how-we-trace-a-kv-database-with...). Since Go purposefully (and reasonably) doesn't currently provide a comparable abstraction for thread-local storage, we can't implement similar tricks like special-casing when a trace is modified on a single thread.
- malkia 1y agoThere is an effort to use arrow format for metrics too - https://github.com/open-telemetry/otel-arrow https://github.com/open-telemetry/otel-arrow - but no client that exports directly to it yet.
- lquerel 1y ago[dead]
- rastignack 1y agoWould the sync.Pool trick mentionned here: https://hypermode.com/blog/introducing-ristretto-high-perf-go-cache https://hypermode.com/blog/introducing-ristretto-high-perf-g... help ? It’s lossy but might be a good compromise.
- sa46 1y agoIt might be. I've seen the trick pop up a few times: 1. https://puzpuzpuz.dev/thread-local-state-in-go-huh https://puzpuzpuz.dev/thread-local-state-in-go-huh 2. https://victoriametrics.com/blog/go-sync-pool/ https://victoriametrics.com/blog/go-sync-pool/ It's probably too complex for the Otel SDK, but I might give it a spin in my experimental tracing repo.