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

@@ -114,4 +114,16 @@ public sealed class StreamSourceConfig
// Defaults to 0 (disabled). When > 0, duplicate messages with the same Nats-Msg-Id
// within this window are silently dropped.
public int DuplicateWindowMs { get; set; }
// Go: StreamSource.SubjectTransforms — per-source subject transforms.
// Reference: golang/nats-server/server/stream.go — SubjectTransforms field.
public List<SubjectTransformConfig> SubjectTransforms { get; set; } = [];
}
// Go: SubjectTransformConfig — source/destination subject transform pair.
// Reference: golang/nats-server/server/stream.go — SubjectTransformConfig struct.
public sealed class SubjectTransformConfig
{
public string Source { get; set; } = string.Empty;
public string Destination { get; set; } = string.Empty;
}