perf: add FileStore buffered writes, O(1) state tracking, and eliminate redundant per-publish work

Implement Go-parity background flush loop (coalesce 16KB/8ms) in MsgBlock/FileStore,
replace O(n) GetStateAsync with incremental counters, skip PruneExpired/LoadAsync/
PrunePerSubject when not needed, and bypass RAFT for single-replica streams. Fix counter
tracking bugs in RemoveMsg/EraseMsg/TTL expiry and ObjectDisposedException races in
flush loop disposal. FileStore optimizations verified with 3112/3112 JetStream tests
passing; async publish benchmark remains at ~174 msg/s due to E2E protocol path bottleneck.
This commit is contained in:
Joseph Doherty
2026-03-13 03:11:11 -04:00
parent 37575dc41c
commit 4de691c9c5
30 changed files with 1514 additions and 185 deletions

View File

@@ -47,7 +47,7 @@ public class JetStreamGoParityTests
// Discard new policy rejects messages when stream is full.
// =========================================================================
[Fact(Skip = "DiscardPolicy.New enforcement for MaxMsgs not yet implemented in .NET server — only MaxBytes is checked")]
[Fact]
public async Task AddStream_discard_new_rejects_when_full()
{
// Go: TestJetStreamAddStreamDiscardNew jetstream_test.go:236
@@ -675,7 +675,7 @@ public class JetStreamGoParityTests
// Consumer with DeliverPolicy.New
// =========================================================================
[Fact(Skip = "DeliverPolicy.New initial sequence resolved lazily at fetch time, not at consumer creation — sees post-fetch state")]
[Fact]
public async Task Consumer_deliver_new_only_gets_new_messages()
{
// Go: deliver new policy tests
@@ -723,7 +723,7 @@ public class JetStreamGoParityTests
// Stream overlapping subjects rejected
// =========================================================================
[Fact(Skip = "Overlapping subject validation across streams not yet implemented in .NET server")]
[Fact]
public async Task Stream_overlapping_subjects_rejected()
{
// Go: TestJetStreamAddStreamOverlappingSubjects jetstream_test.go:615
@@ -758,7 +758,7 @@ public class JetStreamGoParityTests
// Stream sealed prevents new messages
// =========================================================================
[Fact(Skip = "Sealed stream publish rejection not yet implemented in .NET server Capture path")]
[Fact]
public async Task Stream_sealed_prevents_publishing()
{
// Go: sealed stream tests