Skip to content

perf(profiling): allocate 512 capacity initially for alloc map#18119

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
gyuheon0h/mem-prof-alloc-map-startup-allocate
May 18, 2026
Merged

perf(profiling): allocate 512 capacity initially for alloc map#18119
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
gyuheon0h/mem-prof-alloc-map-startup-allocate

Conversation

@gyuheon0h
Copy link
Copy Markdown
Contributor

@gyuheon0h gyuheon0h commented May 15, 2026

Description

flat_hash_map rehashes at 87.5% load (https://abseil.io/docs/cpp/guides/container#hash-tables) doubling capacity each time. Without this, growing from 0 to 1024 entries triggers ~8 rehashes:
capacity: 4 -> 8 -> 16 -> 32 -> 64 -> 128 -> 256 -> 512 -> 1024
rehash at: 4 7 14 28 56 112 224 448

p99 live heap count is ~350

Each rehash at capacity N copies all N existing entries.

This only minorly improves startup, but this is a cheap non-negative change

Testing

Risks

Additional Notes

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gyuheon0h gyuheon0h changed the title Allocate 1024 capacity initially perf(profiling): allocate 1024 capacity initially for alloc map May 15, 2026
@gyuheon0h gyuheon0h added the changelog/no-changelog A changelog entry is not required for this PR. label May 15, 2026
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Codeowners resolved as

ddtrace/profiling/collector/_memalloc_heap.cpp                          @DataDog/profiling-python

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/mem-prof-alloc-map-startup-allocate branch 3 times, most recently from 9d7d459 to cc01596 Compare May 15, 2026 18:32
@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 15, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2242e8c | Docs | Datadog PR Page | Give us feedback!

@gyuheon0h gyuheon0h marked this pull request as ready for review May 15, 2026 18:44
@gyuheon0h gyuheon0h requested a review from a team as a code owner May 15, 2026 18:44
@gyuheon0h gyuheon0h requested a review from KowalskiThomas May 15, 2026 18:44
Comment thread ddtrace/profiling/collector/_memalloc_heap.cpp Outdated
@gyuheon0h gyuheon0h requested a review from taegyunkim May 15, 2026 19:42
@gyuheon0h gyuheon0h force-pushed the gyuheon0h/mem-prof-alloc-map-startup-allocate branch from 66ceb57 to ebbfc0f Compare May 15, 2026 19:47
Copy link
Copy Markdown
Contributor

@KowalskiThomas KowalskiThomas left a comment

Choose a reason for hiding this comment

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

I have nothing against this but FWIW I've never seen rehashes show up in profiles so it's probably not going to change much.

Comment thread ddtrace/profiling/collector/_memalloc_heap.cpp Outdated
@gyuheon0h gyuheon0h force-pushed the gyuheon0h/mem-prof-alloc-map-startup-allocate branch from 57aadce to 04be43f Compare May 18, 2026 14:04
@gyuheon0h gyuheon0h changed the title perf(profiling): allocate 1024 capacity initially for alloc map perf(profiling): allocate 512 capacity initially for alloc map May 18, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit acbd378 into main May 18, 2026
403 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the gyuheon0h/mem-prof-alloc-map-startup-allocate branch May 18, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants