Skip to content

Conversation

@blt
Copy link
Collaborator

@blt blt commented Jan 12, 2026

Summary

  • Replace Vec<String> tag storage with Vec<Tag> containing Pool handles
  • Eliminates ~260K String allocations during DogStatsD initialization by storing tag references as (offset, length) handles into the string pool
  • Tags are formatted to "key:value" strings at serialization time via Display impls rather than during construction

Performance

With default configs (~7500 contexts × ~26 tags), this significantly reduces init-time memory allocation overhead.

Benchmark results (payloadtool + hyperfine):

  • Main: 175.2ms ± 5.8ms
  • This: 118.6ms ± 2.6ms
  • Improvement: ~32% faster

@blt blt requested a review from a team as a code owner January 12, 2026 22:57
Replace Vec<String> tag storage with Vec<Tag> containing Pool handles.
This eliminates ~260K String allocations during DogStatsD initialization
by storing tag references as (offset, length) handles into the string pool.

Tags are formatted to "key:value" strings at serialization time via
Display impls rather than during construction. With default configs
(~7500 contexts × ~26 tags), this significantly reduces init-time
memory allocation overhead.

Benchmark results (payloadtool + hyperfine):
- Main: 175.2ms ± 5.8ms
- This: 118.6ms ± 2.6ms
- Improvement: ~32% faster
@blt blt force-pushed the blt/optimize-dogstatsd-handle-tags branch from 70a7929 to c9eb5b0 Compare January 12, 2026 23:05
// Use handle-based tagset from core module directly, avoiding String
// allocations. Formatting happens at serialization time with O(1) handle
// lookups.
pub(crate) type Tagset = crate::common::tags::Tagset;
Copy link
Contributor

Choose a reason for hiding this comment

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

Light rec to use crate::...::tagset here and move the comment onto that type if relevant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved in e5c3a7f

Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
@blt blt enabled auto-merge (squash) January 13, 2026 00:16
@blt blt merged commit 62d08c1 into main Jan 13, 2026
26 checks passed
@blt blt deleted the blt/optimize-dogstatsd-handle-tags branch January 13, 2026 00:24
blt added a commit that referenced this pull request Jan 15, 2026
Refactor skills to reduce token usage while preserving functionality:
- Extract shared BENCHMARKING.md and DB_SCHEMA.md references
- Remove duplicated bash blocks (worktree, criterion, hyperfine)
- Convert verbose tutorials to concise checklists
- Trust LLM knowledge of bash/Rust basics

Based on analysis of merged PRs, establishes a standard commit format:
- Title: Action verb + target + technique (no prefixes)
- Body: Brief explanation + benchmark results
- ONE commit per optimization (includes db.yaml update)

Examples from merged PRs analyzed:
- Reuse buffer in Apache Common serialization (#1690)
- Eliminate allocations in Splunk HEC serialization (#1694)
- Use handle-based tag storage in DogStatsD (#1691)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants