Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
bc42093
Trim per-span work on metrics aggregator publish path
dougqh May 15, 2026
808d63d
Add SpanKindFilter and CoreSpan.isKind for bitmask-based kind checks
dougqh May 15, 2026
6aa620e
Use SpanKindFilter in ConflatingMetricsAggregator
dougqh May 15, 2026
a02d0a9
Add DDSpan-based variant of ConflatingMetricsAggregator JMH benchmark
dougqh May 15, 2026
ed38f18
Tighten SpanKindFilter encapsulation
dougqh May 15, 2026
034afc0
Defer MetricKey construction and cache lookups to the aggregator thread
dougqh May 15, 2026
3a056b3
Report aggregator inbox-full drops via health metrics
dougqh May 15, 2026
3355865
Merge branch 'master' into dougqh/conflating-metrics-producer-wins
dougqh May 18, 2026
950499c
Merge branch 'dougqh/conflating-metrics-producer-wins' into dougqh/co…
dougqh May 18, 2026
0294058
Add Hashtable and LongHashingUtils to datadog.trace.util
dougqh May 18, 2026
f751ab4
Add AggregateTable + AggregateEntry backed by Hashtable
dougqh May 15, 2026
f1b030a
Swap LRUCache for AggregateTable in Aggregator + route disable() clear
dougqh May 15, 2026
3738c85
Eliminate MetricKey: inline its fields onto AggregateEntry
dougqh May 15, 2026
46a9055
Add unit tests for Hashtable and LongHashingUtils
dougqh May 18, 2026
031dc89
Apply spotless formatting to Hashtable and LongHashingUtils
dougqh May 18, 2026
f9e63b9
Add JMH benchmarks for Hashtable.D1 and D2
dougqh May 18, 2026
a534e4f
Add benchmark results to HashtableBenchmark header
dougqh May 18, 2026
ba66a36
Address review feedback on Hashtable
dougqh May 19, 2026
3108941
Fix dropped argument in HashingUtils 5-arg Object hash
dougqh May 19, 2026
1415f12
Address review feedback on Hashtable
dougqh May 19, 2026
b7cee2f
Drop reflection in iterator tests via package-private D1.buckets
dougqh May 19, 2026
8414960
Resize previousCounts for inbox-full health metric
dougqh May 19, 2026
553ffb8
Fold AggregateMetric into AggregateEntry
dougqh May 19, 2026
07ed635
Avoid capturing lambda in Aggregator.report
dougqh May 19, 2026
df58ad7
Add context-passing forEach to Hashtable.D1 and D2
dougqh May 19, 2026
9c6e95c
Move forEach loop body to Support helper
dougqh May 19, 2026
7ab47f7
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 19, 2026
590ab4a
Delegate AggregateTable.forEach to Support.forEach
dougqh May 19, 2026
447ea33
Move bucket-head cast to Support.bucket helper
dougqh May 19, 2026
46f147a
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 19, 2026
dd5e13f
Use Support.bucket and type chain walks as AggregateEntry
dougqh May 19, 2026
df7f98f
Drop d1_/d2_ prefix from per-table benchmark methods
dougqh May 19, 2026
e6ecc16
Add Hashtable.Support helpers: MAX_RATIO, insertHeadEntry, MutatingTa…
dougqh May 19, 2026
a409d5d
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 19, 2026
96b40b8
Simplify AggregateTable via new Hashtable.Support helpers
dougqh May 19, 2026
55ca204
Swap MAX_RATIO numerator/denominator pair for a single float + scaled…
dougqh May 19, 2026
7b9eccd
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 19, 2026
192de0c
Address second-round review on AggregateTable / Aggregator
dougqh May 19, 2026
4bac439
Tighten Hashtable docs + rename MAX_CAPACITY to MAX_BUCKETS
dougqh May 19, 2026
de289a0
Dedupe chain-head splice in D1/D2 via keyHash insertHeadEntry overload
dougqh May 19, 2026
2dd65ed
Tighten Entry.next encapsulation; doc hasNext; add D1/D2 getOrCreate
dougqh May 19, 2026
cc8d98a
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 19, 2026
6a9063b
Use keyHash insertHeadEntry overload in AggregateTable.findOrInsert
dougqh May 19, 2026
dbb1702
Replace // nullable comments with @Nullable annotations on AggregateE…
dougqh May 19, 2026
545e74c
Drop redundant load-factor comment from AggregateTable ctor
dougqh May 19, 2026
9983a59
Import java.util.Objects in AggregateEntry instead of fully qualifying
dougqh May 19, 2026
d2e4477
Document evictOneStale cost and disable() best-effort offer
dougqh May 19, 2026
24969db
Skip SpanSnapshot allocation when the inbox is already at capacity
dougqh May 19, 2026
66ec7f6
Hashtable: add missing braces and detach removed/replaced entries
dougqh May 20, 2026
be823ab
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 20, 2026
10956b2
Add Hashtable and LongHashingUtils to datadog.trace.util
dougqh May 18, 2026
035dc09
Add unit tests for Hashtable and LongHashingUtils
dougqh May 18, 2026
7728b60
Apply spotless formatting to Hashtable and LongHashingUtils
dougqh May 18, 2026
8cd2d86
Add JMH benchmarks for Hashtable.D1 and D2
dougqh May 18, 2026
c689ef9
Add benchmark results to HashtableBenchmark header
dougqh May 18, 2026
75790eb
Address review feedback on Hashtable
dougqh May 19, 2026
6056ff7
Fix dropped argument in HashingUtils 5-arg Object hash
dougqh May 19, 2026
da55021
Address review feedback on Hashtable
dougqh May 19, 2026
8b8b088
Drop reflection in iterator tests via package-private D1.buckets
dougqh May 19, 2026
0fde7cd
Add context-passing forEach to Hashtable.D1 and D2
dougqh May 19, 2026
6d6c2e0
Move forEach loop body to Support helper
dougqh May 19, 2026
268de2b
Move bucket-head cast to Support.bucket helper
dougqh May 19, 2026
93813b9
Drop d1_/d2_ prefix from per-table benchmark methods
dougqh May 19, 2026
11a58bf
Add Hashtable.Support helpers: MAX_RATIO, insertHeadEntry, MutatingTa…
dougqh May 19, 2026
8f1828d
Swap MAX_RATIO numerator/denominator pair for a single float + scaled…
dougqh May 19, 2026
c0d3e26
Tighten Hashtable docs + rename MAX_CAPACITY to MAX_BUCKETS
dougqh May 19, 2026
a0978ba
Dedupe chain-head splice in D1/D2 via keyHash insertHeadEntry overload
dougqh May 19, 2026
e604a8f
Tighten Entry.next encapsulation; doc hasNext; add D1/D2 getOrCreate
dougqh May 19, 2026
e2642cd
Hashtable: add missing braces and detach removed/replaced entries
dougqh May 20, 2026
585ca56
Rename LongHashingUtils.hashCodeX(Object) to hash(Object) for API con…
dougqh May 20, 2026
aab5b3b
Merge remote-tracking branch 'origin/master' into dougqh/optimize-met…
dougqh May 20, 2026
88f169f
Merge branch 'dougqh/util-hashtable' into dougqh/optimize-metric-key
dougqh May 20, 2026
795ba76
Merge remote-tracking branch 'origin/master' into dougqh/conflating-m…
dougqh May 20, 2026
e455801
Introduce slim PeerTagSchema; capture peer-tag values not pairs
dougqh May 20, 2026
c2ff012
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 20, 2026
e766fd3
Address PR #11381 review (round 2)
dougqh May 21, 2026
8cfa4a5
Cover inbox-full fast-path in ConflatingMetricsAggregator.publish
dougqh May 21, 2026
3644470
Reconcile PeerTagSchema once per reporting cycle on the aggregator th…
dougqh May 21, 2026
1d1ba4d
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
e7d0b42
Add bootstrap + reconcile coverage for PeerTagSchema
dougqh May 21, 2026
3d4f380
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
9391c48
Use writer.finishBucket() count in bootstrap test for cascade compati…
dougqh May 21, 2026
ba3225c
Use writer.finishBucket() count in bootstrap test for cascade compati…
dougqh May 21, 2026
ec857b2
Merge branch 'master' into dougqh/conflating-metrics-background-work
dougqh May 21, 2026
ba0d390
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
0b86066
Preserve TRACER_METRICS_MAX_PENDING semantic + drop stale imports
dougqh May 21, 2026
f71384e
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
5c78dbb
Add AdversarialMetricsBenchmark for capacity-bound stress testing
dougqh May 21, 2026
471f8f7
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
70c20ef
Trim AdversarialMetricsBenchmark counters and clarify printout
dougqh May 21, 2026
7a074e0
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
68848ad
Close PeerTagSchema reconcile race + cover the swap branch
dougqh May 21, 2026
3fa7ac7
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
df3b31d
Adapt reconcileSwapsSchemaWhenTagSetChanges to AggregateEntry shape
dougqh May 21, 2026
2ea61c5
Clarify materializePeerTags hit-counting loop
dougqh May 21, 2026
8ec956d
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
a606692
Fix MetricsIntegrationTest entry recording call site
dougqh May 21, 2026
913e7d7
Make ConflatingMetricAggregatorTest counter checks actually verify
dougqh May 21, 2026
2dcea9a
Drop dead recordDurations(int, AtomicLongArray) batch API
dougqh May 21, 2026
50b06e5
Warn about colon split in AggregateEntry.of test factory
dougqh May 21, 2026
b0f21bf
Add coverage for disable() -> ClearSignal threading path
dougqh May 21, 2026
5a4685f
Drop unused Tags imports flagged by codenarc
dougqh May 21, 2026
200028d
Merge branch 'dougqh/conflating-metrics-background-work' into dougqh/…
dougqh May 21, 2026
a1863db
Update dd-trace-core/src/main/java/datadog/trace/common/metrics/PeerT…
dougqh May 22, 2026
a75bc4a
Address sarahchen6's review pass
dougqh May 22, 2026
4871892
Clamp TRACER_METRICS_MAX_PENDING instead of throwing on overflow
dougqh May 22, 2026
5f73c2d
Fix duplicate-entry bug for null-fielded SpanSnapshots
dougqh May 22, 2026
9dddf0a
Clear dirty flag in ClearSignal handler
dougqh May 22, 2026
2c8ad26
Merge branch 'master' into dougqh/conflating-metrics-background-work
dougqh May 22, 2026
80778c4
Drop conditional null-skip from peer-tag hashing
dougqh May 22, 2026
21e7545
Delete dead Aggregator.clearAggregates()
dougqh May 22, 2026
877d95c
Cursor-resume eviction in AggregateTable via half-open MutatingTableI…
dougqh May 22, 2026
e2f2585
Move AggregateEntry.of() test factory out of production class
dougqh May 22, 2026
2536aa2
Fix AggregateEntry equals/hashCode contract violation
dougqh May 22, 2026
c0449a3
Don't trample queued STOP in ClearSignal handler
dougqh May 22, 2026
be13431
Implement PeerTagSchema.equals symmetric with hashCode
dougqh May 22, 2026
d174938
Route service and spanKind through canonicalize for null-safety
dougqh May 22, 2026
641b5ef
Suppress forbiddenApis for tearDown's System.err diagnostics
dougqh May 22, 2026
7eedb25
Merge branch 'master' into dougqh/conflating-metrics-background-work
dougqh May 22, 2026
ce5b38b
Use DDAgentFeaturesDiscovery.state() hash for PeerTagSchema reconcile
dougqh May 22, 2026
2eaa58f
Convert TRACER_METRICS_MAX_PENDING rationale to /* */ block comment
dougqh May 22, 2026
cd56981
Merge remote-tracking branch 'origin/dougqh/conflating-metrics-backgr…
dougqh May 22, 2026
d1df95e
Add cardinality-isolation companions to AdversarialMetricsBenchmark
dougqh May 22, 2026
4a4b72e
Merge remote-tracking branch 'origin/dougqh/conflating-metrics-backgr…
dougqh May 22, 2026
133d3c1
Consolidate contentEquals; remove redundant stringContentEquals
dougqh May 26, 2026
2ae738b
Rename AggregateEntries -> AggregateEntryFixtures
dougqh May 26, 2026
f68ad4f
Tidy PR-iteration history out of test comments
dougqh May 26, 2026
6fdc2de
Merge remote-tracking branch 'origin/master' into dougqh/optimize-met…
dougqh May 26, 2026
3f32dfd
Merge remote-tracking branch 'origin/master' into dougqh/optimize-met…
dougqh May 26, 2026
2d1536c
Make AggregateEntry.ERROR_TAG / TOP_LEVEL_TAG package-private
dougqh May 26, 2026
5bf4d90
Move AggregateEntry equality contract to test-only helper
dougqh May 26, 2026
a67ac23
Consolidate AggregateEntryFixtures into AggregateEntryTestUtils
dougqh May 26, 2026
1eb6826
Document deliberate cohesion + single-writer invariant on AggregateEntry
dougqh May 26, 2026
d5065f2
Avoid recomputing keyHash on AggregateTable miss
dougqh May 26, 2026
e6f2399
Document AggregateEntry.clear key-field persistence + SignalItem sing…
dougqh May 27, 2026
dcb1898
Drop useless @SuppressFBWarnings on AggregateEntry
dougqh May 27, 2026
a06c2a8
Update stale Javadoc on AggregateEntry's no-equals contract
dougqh May 27, 2026
acf2ffa
Tighten AggregateEntry / PeerTagSchema surface area
dougqh May 27, 2026
ccb4a4b
Tighten AggregateEntry surface — drop one-line factory, doc the conve…
dougqh May 27, 2026
d0c0be8
Merge branch 'master' into dougqh/optimize-metric-key
dougqh May 27, 2026
4af16c1
Drop unused UTF8BytesString import in MetricsIntegrationTest
dougqh May 27, 2026
dcd3407
Merge branch 'master' into dougqh/optimize-metric-key
dougqh May 27, 2026
f2ee559
Lazy-allocate the error latency histogram on AggregateEntry
dougqh May 27, 2026
1d12490
Add MpscRingBuffer for pre-allocated, recyclable slot rings
dougqh May 28, 2026
16b2ec6
Add throughput benchmarks for MpscRingBuffer
dougqh May 28, 2026
e67dde7
Add RingVsQueueBenchmark for MpscRingBuffer vs MpscArrayQueue
dougqh May 28, 2026
059063f
Merge dougqh/ring-buffer into dougqh/css-ring-buffer
dougqh May 28, 2026
7ec3f11
Swap CSS inbox for MpscRingBuffer of mutable SpanSnapshot slots
dougqh May 28, 2026
cec6abf
Document MpscRingBuffer thread-safety contract; publish on filler throw
dougqh May 28, 2026
1940355
Merge dougqh/ring-buffer into dougqh/css-ring-buffer
dougqh May 28, 2026
9162a1e
Use AtomicLongFieldUpdater for the producer cursor
dougqh May 28, 2026
12984ac
Merge dougqh/ring-buffer: pick up AtomicLongFieldUpdater change
dougqh May 28, 2026
e8ead01
Pad MpscRingBuffer cursors and stride publishedSequences
dougqh May 28, 2026
fed8238
Merge dougqh/ring-buffer: cache-line padding + stride
dougqh May 28, 2026
ef046be
Shrink tracer.metrics defaults at Xmx<128m for the ring buffer
dougqh May 28, 2026
525599e
Cut default tracer.metrics.max.pending from 2048 to 128
dougqh May 28, 2026
c31715f
Reuse peerTagValues array across publishes via slot-owned scratch
dougqh May 28, 2026
7e6f497
Add MpscRingBuffer.tryClaim(n) batch-claim API
dougqh May 28, 2026
01754a5
Merge dougqh/ring-buffer: pick up tryClaim(n)/Batch API
dougqh May 28, 2026
3324952
Use Batch claim for CSS publish(trace)
dougqh May 28, 2026
780a204
Add low-level tryClaimRange/slotAt/publish primitives to MpscRingBuffer
dougqh May 28, 2026
f18a73e
Merge dougqh/ring-buffer: pick up low-level primitives
dougqh May 28, 2026
32c69d1
Use MpscRingBuffer low-level primitives in publish(trace)
dougqh May 28, 2026
e4277d0
Fix stale Javadoc reference to removed slotFiller field
dougqh May 28, 2026
fb14c62
Overclaim + skip-sentinel in CSS publish(trace): one pass, no Batch
dougqh May 28, 2026
e29b802
Use PendingTrace pre-counted eligible-span count for exact CSS ring c…
dougqh May 28, 2026
21b5bd7
Revert "Use PendingTrace pre-counted eligible-span count for exact CS…
dougqh May 28, 2026
a39ede1
Park/unpark aggregator and cache PeerTagSchema.namesHash
dougqh May 29, 2026
c330d9c
Canonicalize + hash on the producer; identity matches on the aggregator
dougqh May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
package datadog.trace.util.concurrent;

import static java.util.concurrent.TimeUnit.SECONDS;

import java.util.function.BiConsumer;
import org.jctools.queues.MpscArrayQueue;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.GroupThreads;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

/**
* Head-to-head comparison of {@link MpscRingBuffer} (mutable pre-allocated slots) against the
* conventional approach of a jctools {@link MpscArrayQueue} with a fresh {@code Slot} allocated per
* publish. The latter is the pattern the current CSS code uses for {@code SpanSnapshot} on the
* producer side, so the delta between the two measures the actual allocation/handoff saving of the
* ring-buffer rewrite.
*
* <ul>
* <li>{@code write_*_8p} — 8 producers, background drainer keeps the structure empty so the
* measurement reflects publish cost, not full-structure drop cost. Pair-compare ring vs queue
* at matched capacity.
* <li>{@code e2e_*_8p} — JMH {@code @Group} pairing 8 producers with 1 consumer for each
* structure. End-to-end ops/s under realistic backpressure.
* </ul>
*
* <p>Run with {@code -prof gc} to also see per-op allocation rate — that's where the ring's win is
* loudest, since the queue allocates one {@code Slot} per publish and the ring allocates none.
*/
@State(Scope.Benchmark)
@Warmup(iterations = 2, time = 15, timeUnit = SECONDS)
@Measurement(iterations = 5, time = 15, timeUnit = SECONDS)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(SECONDS)
@Fork(value = 1)
public class RingVsQueueBenchmark {

/**
* Shared slot type. {@code MpscRingBuffer} pre-allocates these and the producer mutates in place;
* the queue path allocates a fresh one per publish and offers the reference. Two constructors so
* both styles read naturally.
*/
public static final class Slot {
long value;

Slot() {}

Slot(final long value) {
this.value = value;
}
}

// Static (non-capturing) handlers. Passing ts/bh as context lets the JIT keep these as
// singleton functions and avoid per-call lambda allocation.
private static final BiConsumer<ThreadState, Slot> RING_FILLER =
(ts, slot) -> {
slot.value = ts.counter;
ts.counter++;
};

private static final BiConsumer<Blackhole, Slot> RING_CONSUMER =
(bh, slot) -> bh.consume(slot.value);

@Param({"1024"})
public int capacity;

/** Write-side benchmark structures. Drained by a background thread so they never fill. */
MpscRingBuffer<Slot> ring;

MpscArrayQueue<Slot> queue;

/** E2e benchmark structures. JMH drives both sides via {@code @Group}; no background drainer. */
MpscRingBuffer<Slot> e2eRing;

MpscArrayQueue<Slot> e2eQueue;

private volatile boolean stopDrainers;
private Thread ringDrainer;
private Thread queueDrainer;

@Setup(Level.Trial)
public void setup() {
ring = new MpscRingBuffer<>(Slot::new, capacity);
queue = new MpscArrayQueue<>(capacity);
e2eRing = new MpscRingBuffer<>(Slot::new, capacity);
e2eQueue = new MpscArrayQueue<>(capacity);

stopDrainers = false;
ringDrainer =
new Thread(
() -> {
while (!stopDrainers) {
if (ring.drain((Slot s) -> {}) == 0) Thread.yield();
}
},
"RingVsQueueBenchmark-ringDrainer");
ringDrainer.setDaemon(true);
ringDrainer.start();

queueDrainer =
new Thread(
() -> {
while (!stopDrainers) {
Slot s = queue.poll();
if (s == null) Thread.yield();
}
},
"RingVsQueueBenchmark-queueDrainer");
queueDrainer.setDaemon(true);
queueDrainer.start();
}

@TearDown(Level.Trial)
public void teardown() throws InterruptedException {
stopDrainers = true;
ringDrainer.join(5_000);
queueDrainer.join(5_000);
}

@State(Scope.Thread)
public static class ThreadState {
long counter;
}

// ============ Write-side throughput ============

@Threads(8)
@Benchmark
public boolean write_ring_8p(final ThreadState ts) {
return ring.tryWrite(ts, RING_FILLER);
}

/** Mirrors the SpanSnapshot pattern: allocate a fresh instance per publish, offer it. */
@Threads(8)
@Benchmark
public boolean write_queue_8p(final ThreadState ts) {
return queue.offer(new Slot(ts.counter++));
}

// ============ End-to-end producer/consumer ============

@Group("e2e_ring_8p")
@GroupThreads(8)
@Benchmark
public boolean e2e_ring_producer(final ThreadState ts) {
return e2eRing.tryWrite(ts, RING_FILLER);
}

@Group("e2e_ring_8p")
@GroupThreads(1)
@Benchmark
public int e2e_ring_consumer(final Blackhole bh) {
int drained = e2eRing.drain(bh, RING_CONSUMER);
if (drained == 0) Thread.yield();
return drained;
}

@Group("e2e_queue_8p")
@GroupThreads(8)
@Benchmark
public boolean e2e_queue_producer(final ThreadState ts) {
return e2eQueue.offer(new Slot(ts.counter++));
}

@Group("e2e_queue_8p")
@GroupThreads(1)
@Benchmark
public int e2e_queue_consumer(final Blackhole bh) {
int drained = 0;
Slot slot;
while ((slot = e2eQueue.poll()) != null) {
bh.consume(slot.value);
drained++;
}
if (drained == 0) Thread.yield();
return drained;
}
}
Loading