You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
StreamingBenchmarkTests.testMemoryUsageWith2MBChunk asserts peak memory < 70 MB when streaming-encrypting a 50 MB file in 2 MB chunks, but actual peak is ~213 MB — over 3× the threshold. The test fails deterministically locally and is environment-flaky in CI's test job.
Evidence
OpenTDFKitTests/StreamingBenchmarkTests.swift:156
XCTAssertLessThan(peakMemory, Int64(70 * 1024 * 1024), "Peak memory should be less than 70MB for 50MB file")
// XCTAssertLessThan failed: ("213483520") is not less than ("73400320")
Fails in both debug and release (swift test and swift test -c release) → not a debug-only artifact.
Flaky in CI: the test job runs all tests in debug, including this benchmark; it has passed some CI runs and failed others depending on memory-measurement timing.
Why it matters
A perpetually-/intermittently-red test job hides real regressions. This (together with a now-fixed stale unwrap test) kept the test check red on main from 2026-03-20, which masked other failures.
It may indicate a real memory inefficiency — a streaming encryptor processing 2 MB chunks of a 50 MB file should not need to hold ~213 MB resident. Worth confirming whether TDFEncryptor.encryptFile is buffering more than it should (e.g. holding the whole input/output in memory) rather than truly streaming.
Proposed remediation (pick per investigation)
Investigate TDFEncryptor.encryptFile peak memory for chunked input. If it's genuinely buffering the whole file, fix the streaming path (the real win). If ~213 MB is expected/acceptable, recalibrate the assertion to a realistic, stable bound.
Move the benchmark suites (*BenchmarkTests) out of the default test job so test is deterministic — they already have a dedicated benchmark job (release). Memory/timing assertions don't belong in the correctness gate.
Repro
swift test --filter "StreamingBenchmarkTests/testMemoryUsageWith2MBChunk"
swift test -c release --filter "StreamingBenchmarkTests/testMemoryUsageWith2MBChunk"
Summary
StreamingBenchmarkTests.testMemoryUsageWith2MBChunkasserts peak memory < 70 MB when streaming-encrypting a 50 MB file in 2 MB chunks, but actual peak is ~213 MB — over 3× the threshold. The test fails deterministically locally and is environment-flaky in CI'stestjob.Evidence
OpenTDFKitTests/StreamingBenchmarkTests.swift:156swift testandswift test -c release) → not a debug-only artifact.77920b3(predates the ConnectRPC work in feat(kas)!: ConnectRPC transport + well-known discovery (CWT) #39).testjob runs all tests in debug, including this benchmark; it has passed some CI runs and failed others depending on memory-measurement timing.Why it matters
testjob hides real regressions. This (together with a now-fixed stale unwrap test) kept thetestcheck red onmainfrom 2026-03-20, which masked other failures.TDFEncryptor.encryptFileis buffering more than it should (e.g. holding the whole input/output in memory) rather than truly streaming.Proposed remediation (pick per investigation)
TDFEncryptor.encryptFilepeak memory for chunked input. If it's genuinely buffering the whole file, fix the streaming path (the real win). If ~213 MB is expected/acceptable, recalibrate the assertion to a realistic, stable bound.*BenchmarkTests) out of the defaulttestjob sotestis deterministic — they already have a dedicatedbenchmarkjob (release). Memory/timing assertions don't belong in the correctness gate.Repro
Surfaced while getting CI green for #39.