Performance improvements in the Datadog Agent metrics pipeline
Profiling the Go-based Datadog Agent under heavy DogStatsD load showed that computing a unique context key per metric, especially sorting and deduplicating tags, dominated CPU. Datadog specialized the sort by tag count, switched to murmur3 with 64-bit keys to hit Go's fast map paths, and then replaced ordered hash chaining with order-independent XOR of tag hashes, deduplicated through a reusable fixed-size custom hash set that removes sorting entirely. Micro-benchmarks show context generation 11–80% faster depending on tag count, and at ~200k metrics/s on 4-core VMs Agent CPU fell about 40% (1 core vs 1.6).
Related posts
- Scaling down to speed up: How we improved efficiency of live process metrics by 100x
Datadog Engineering mediumAdeptDatadog cut real-time process and container metric traffic by about 100x by enabling 2-second live collection only on hosts whose processes a user is actually viewing (at most 50 per user), instead of on every host in the tenant. Sorting switched to the existing 10-second data, which removed the need to hold all live metrics in a single server's memory. Host subscriptions are published over Kafka at 1-second intervals to the intake service, which keeps a TTL-based in-memory cache of viewed hosts. Peak volume fell from 500,000 to 5,000 messages per second, the live data service shrank by about 98% (over 600 cores and 1 TiB of memory freed), and Agent CPU usage dropped about 2%.
- How we scaled metrics aggregation by moving durable state into storage
Datadog Engineering mediumAdeptDatadog's metrics aggregation service, which merges DDSketch distributions to reduce tag dimensions, went through three generations as volume grew roughly 10× each time. Static leader-follower partitions with local RocksDB doubled compute and needed manual partition splits. Dynamic Kafka assignment with incremental SSTable snapshots to blob storage and time-windowed lazy restore improved recovery and enabled autoscaling, but state recovery then became the bottleneck. The third generation makes streaming aggregation and deduplication best-effort. Both storage tiers reconcile partial aggregates, duplicates and late data during reads and compaction, so workers can restart at the live edge without restoring hours of state and can be provisioned for current traffic.
- From hand-tuned Go to self-optimizing code: Building BitsEvolve
Datadog Engineering mediumAdeptDatadog cut CPU in Go hot paths by removing compiler bounds checks in NormalizeTag (25% faster, 0.75% service CPU) and adding an ASCII fast path to NormalizeTagArbTagValue (90% faster, hundreds of thousands of dollars in projected annual savings), guided by production data showing nearly all inputs were ASCII. These manual techniques became the heuristics for BitsEvolve, an AlphaEvolve-inspired agent that uses an island-model evolutionary algorithm, benchmark fitness functions and Temporal orchestration to mutate code. BitsEvolve rediscovered the hand-tuned versions and improved Murmur3 and CRC32 by about 20%. The key lesson is that realistic benchmarks matter, so production data captured with Live Debugger is used to build trustworthy fitness functions, and the work then extends toward SIMD kernels for Go.
- How Uken Games reduces observability costs by 87% with ClickHouse
ClickHouse mediumAdept
Uken Games replaced Datadog with an open-source observability stack: OpenTelemetry collectors in an agent-plus-gateway layout, SigNoz on a single ClickHouse node for traces, AWS-managed Prometheus for metrics, CloudWatch for logs, and Grafana alerts defined as code via a custom CloudFormation resource. All traces fit in about 170 GB on one ClickHouse node, the migration had zero downtime, and annual cost fell about 87% to roughly $12,000. Key cost levers were dropping unused metrics and attributes, tail-style trace sampling that keeps errors and slow requests plus a 5–10% sample, alerting on unsampled aggregate metrics, and capping retention at two weeks.
- How we reduced the size of our Agent Go binaries by up to 77%
Datadog Engineering mediumAdeptDatadog cut its Agent's Go binary sizes by up to 77% between versions 7.60.0 and 7.68.0 without removing features. The work combined three things: auditing imports with go list, goda and go-size-analyzer; moving code behind build tags or into separate packages; and re-enabling the linker's method dead code elimination. The last required finding reflect.MethodByName uses with -dumpdep and whydeadcode, patching about a dozen dependencies and forking text/template, which yielded 16–25% per binary. A single misplaced function had pulled 570 Kubernetes packages into trace-agent, about 36 MiB, and similar fixes upstream gave Kubernetes 16–37% reductions.