enhancement(dogstatsd): batch datagram decoder dequeues - #2275
Conversation
Drain up to 32 queued datagrams per shared receiver lock acquisition to amortize async mutex and channel wakeup overhead. Local closed-loop UDS benchmarks improved realistic-profile throughput by about 8% on a two-CPU target.
Binary Size Analysis (Agent Data Plane)Baseline: c356375 · Comparison: a7f8350 · diff ✅ Binary size difference within thresholdChanges by Module
Detailed Symbol Changes |
Compile the ReceivedBuffer test accessors only on Unix, matching their Unix-only call sites and avoiding dead-code failures in Windows unit-test builds.
Regression Detector (Agent Data Plane)Run ID: Optimization Goals: ❌ 3 regressions detected
Fine details of change detection per experiment (2)Experiments configured
Bounds Checks: ❌ Failed (5)
ExplanationA change is flagged as a regression when |Δ mean %| > 5.00% in the regressing direction for its optimization goal AND SMP marks the experiment as a regression ( |
There was a problem hiding this comment.
More details
The batched decoder preserves FIFO processing, per-datagram socket context, and shutdown draining while reducing receiver-lock overhead. No behavioral regression was identified; focused execution could not reach compilation because the sandbox lacks the git-pinned hyper-http-proxy dependency and cannot access the network.
🤖 Datadog Autotest · Commit a7f8350 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
webern
left a comment
There was a problem hiding this comment.
Mostly nits other than the memory regression detector.
There was a problem hiding this comment.
I found this description slightly lacking. Here is a more suggested, fuller description.
When a completion file is requested, Millstone writes a marker after to signal that it has finished sending, then remains alive instead of exiting. This lets callers detect that sending is complete while preserving the sender’s process identity for origin detection.
There was a problem hiding this comment.
Writing this comment after the suggestion in main.rs. I am slightly confused as to whether millstone will wait indefinitely when writing a completion file or whether it is interacting with FLUSH_WAIT somehow.
There was a problem hiding this comment.
Nit: just because Pinned and Unpinned mean something specific in Rust code.
| Resolved(Option<EntityId>), | |
| Unresolved(u32), |
There was a problem hiding this comment.
nit: Pinned and Unpinned are overloaded because of the Rust meanings. Also I thought a bit of documentation could help the reader here.
| /// The outcome of origin resolution at the time of message decoding. | |
| #[derive(Clone, Debug, Eq, PartialEq)] | |
| pub(super) enum ProcessOrigin { | |
| /// The resolver ran when the message was decoded. | |
| Resolved(Option<EntityId>), | |
| /// Only the PID is available, the resolver did not run. | |
| Unresolved(u32), | |
| /// The traffic is generated by replay, use the replay PID. | |
| Replay(u32), |
| debug!(listen_addr = %socket_context.listen_addr, "Datagram reader started."); | ||
|
|
||
| loop { | ||
| memory_limiter.wait_for_capacity().await; |
There was a problem hiding this comment.
If I understand correctly, this provides backpressure before starting another receive cycle. Is it the allocations downstream from here that are causing the RSS regressions in the regression detector? Or is it the larger number of BytesBuffers themselves?
Summary
This is stacked on #2079.
Receiver::recv_manywakes as soon as one item is available; it does not wait for the batch to fill. Low-volume traffic therefore follows the same wait-for-one-message behavior as before.Change Type
How did you test this PR?
Automated validation
make fmtcargo nextest run -p saluki-components dogstatsdcargo xwin check --target x86_64-pc-windows-msvc -p saluki-components --testsClosed-loop UDS throughput benchmark
I used a local experimental Docker/Lading harness rather than committing additional benchmark infrastructure in this PR. The benchmark used:
0-1) and separate two-CPU Lading generator (2-3);Mean throughput improved 8.1%. Mean packet rate increased from approximately 263k datagrams/s to 284k datagrams/s.
I also prototyped Linux
recvmmsgwith per-message UDS credentials. It improved the realistic profile by approximately 0.9% and a small-datagram profile by approximately 1.9%, within local variance, so that additional unsafe and platform-specific code is not included.Trade-offs
References