Repository navigation
perf: split Publisher::send() into separate prefix/value parts - #141
Merged
Merged
Conversation
Author
|
cc @jasonk000 |
Member
|
@akonradi looks like a rebase should fix the build issue, can you try that? thx |
Merged
Avoids a redundant copy: the previous code assembled a complete 'prefix+value' line in a thread-local scratch std::string, then copied that whole line into the Unix-domain transport's accumulation buffer -- the prefix got copied twice per measurement. Publisher::send() now takes the cached per-meter prefix and the freshly-formatted value as two separate string_view parts; the Unix-domain sender appends each straight into its own buffer_, so the prefix is copied into its final resting place exactly once. StatelessMeter::send()/send_uint() format the value directly into a plain stack array (no thread-local std::string staging buffer needed at all now, since there's no longer a combined line to assemble) and pass it on as a view. UDP sends the two parts as one datagram via a 2-buffer asio scatter/gather write -- no scaling concern there, since each UDP send is always exactly these two buffers, never batched with others the way Unix-domain measurements are. No change to the public Id/Tags/Counter/Gauge/.../Registry API. Microbenchmark (300 Counters, 500K Increment() calls, real Unix-domain receiver): ~0.050us/call vs baseline's ~0.056us/call, ~10% faster
akonradi
force-pushed
the
elide-dup-prefix-copy
branch
from
October 7, 2026 17:51
2cd6ac1 to
f826281
Compare
jasonk000
reviewed
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoids a redundant copy: the previous code assembled a complete 'prefix+value' line in a thread-local scratch std::string, then copied that whole line into the Unix-domain transport's accumulation buffer -- the prefix got copied twice per measurement. Publisher::send() now takes the cached per-meter prefix and the freshly-formatted value as two separate string_view parts; the Unix-domain sender appends each straight into its own buffer_, so the prefix is copied into its final resting place exactly once. StatelessMeter::send()/send_uint() format the value directly into a plain stack array (no thread-local std::string staging buffer needed at all now, since there's no longer a combined line to assemble) and pass it on as a view.
UDP sends the two parts as one datagram via a 2-buffer asio scatter/gather write -- no scaling concern there, since each UDP send is always exactly these two buffers, never batched with others the way Unix-domain measurements are.
No change to the public Id/Tags/Counter/Gauge/.../Registry API.
Microbenchmark (300 Counters, 500K Increment() calls, real Unix-domain receiver): ~0.050us/call vs baseline's ~0.056us/call, ~10% faster