Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions tests/Relayer.Tests/SenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ await Assert.That(async () => await sender.SendAsync(new OrderPlaced(Guid.NewGui
await Assert.That(transport.ObservedToken.IsCancellationRequested).IsFalse();
}

// Runtime timer queues share locks across tests and allocate wait state on first contention.
[NotInParallel]
[Test]
[Arguments(false)]
[Arguments(true)]
Expand All @@ -428,14 +426,13 @@ public async Task Direct_send_has_zero_steady_state_allocations_with_the_default
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
var message = new OrderPlaced(Guid.NewGuid());
for (var i = 0; i < 1000; i++) await sender.SendAsync(message);
TimerQueueWarmup.WarmContention();
var before = GC.GetAllocatedBytesForCurrentThread();
for (var i = 0; i < 1000; i++) await sender.SendAsync(message);
var allocated = GC.GetAllocatedBytesForCurrentThread() - before;
await Assert.That(allocated).IsEqualTo(0L);
}

// Runtime timer queues share locks across tests and allocate wait state on first contention.
[NotInParallel]
[Test]
public async Task Overlapping_asynchronous_sends_retain_the_peak_pool_and_allocate_zero_bytes_after_warmup()
{
Expand All @@ -454,6 +451,7 @@ public async Task Overlapping_asynchronous_sends_retain_the_peak_pool_and_alloca
transport.CompleteBatch();
for (var i = 0; i < concurrency; i++) await pending[i];
}
TimerQueueWarmup.WarmContention();
var before = GC.GetAllocatedBytesForCurrentThread();
for (var batch = 0; batch < 20; batch++)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Relayer.Tests/TimerQueueWarmup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static class TimerQueueWarmup
{
// CancelAfter reuses its timer after warmup, but .NET's shared TimerQueue Lock
// allocates a 24 B AutoResetEvent and 32 B SafeWaitHandle on first contention.
// Exercise that native lazy initialization before measuring the batch pipeline.
// Exercise that native lazy initialization before measuring send or batch pipelines.
// This is setup only: do not replace native timers or exclude bytes from a window.
internal static void WarmContention()
{
Expand Down
Loading