feat: add benchmark test project for Go vs .NET server comparison

Side-by-side performance benchmarks using NATS.Client.Core against both
servers on ephemeral ports. Includes core pub/sub, request/reply latency,
and JetStream throughput tests with comparison output and
benchmarks_comparison.md results. Also fixes timestamp flakiness in
StoreInterfaceTests by using explicit timestamps.
This commit is contained in:
Joseph Doherty
2026-03-13 01:23:31 -04:00
parent e9c86c51c3
commit 37575dc41c
28 changed files with 2264 additions and 12 deletions

View File

@@ -286,6 +286,7 @@ public sealed class StoreInterfaceTests
// Go: TestStoreUpdateConfigTTLState server/store_test.go:574
[Fact]
[SlopwatchSuppress("SW004", "TTL expiry test requires real wall-clock time to elapse; Thread.Sleep waits for message TTL to expire or survive")]
public void UpdateConfigTTLState_MessageSurvivesWhenTtlDisabled()
{
var cfg = new StreamConfig
@@ -413,13 +414,12 @@ public sealed class StoreInterfaceTests
var ms = new MemStore();
var s = Sync(ms);
long startTs = 0;
// Use StoreRawMsg with explicit timestamps to avoid flakiness under CPU pressure.
var baseTs = (DateTime.UtcNow.Ticks - DateTime.UnixEpoch.Ticks) * 100L;
for (var i = 0; i < 10; i++)
{
var (_, ts) = s.StoreMsg("foo", null, [], 0);
if (i == 1)
startTs = ts;
}
s.StoreRawMsg("foo", null, [], (ulong)(i + 1), baseTs + i * 1_000_000L, 0, false);
var startTs = baseTs + 1_000_000L; // timestamp of seq 2 (i == 1)
// Create a delete gap in the middle: seqs 4-7 deleted.
// A naive binary search would hit deleted sequences and return wrong result.
@@ -443,13 +443,12 @@ public sealed class StoreInterfaceTests
var ms = new MemStore();
var s = Sync(ms);
long startTs = 0;
// Use StoreRawMsg with explicit timestamps to avoid flakiness under CPU pressure.
var baseTs = (DateTime.UtcNow.Ticks - DateTime.UnixEpoch.Ticks) * 100L;
for (var i = 0; i < 3; i++)
{
var (_, ts) = s.StoreMsg("foo", null, [], 0);
if (i == 1)
startTs = ts;
}
s.StoreRawMsg("foo", null, [], (ulong)(i + 1), baseTs + i * 1_000_000L, 0, false);
var startTs = baseTs + 1_000_000L; // timestamp of seq 2 (i == 1)
// Delete last message — trailing delete.
s.RemoveMsg(3).ShouldBeTrue();