From 21852acc581d7a8ff9d29be63d2820c094d67110 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sun, 19 Apr 2026 12:26:52 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20tighten=20parity=20perf?= =?UTF-8?q?=20guard=20and=20document=20fixture=20constants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `expect(currentMs).toBeLessThan(legacyMs * 3 + 50)` form was dominated by the `+ 50` additive term at typical sub-ms query latencies — at legacy=1ms, a 50x regression would still pass. Replace with `Math.max(legacyMs * 5, 50)` so the multiplicative ceiling is intact once the new path climbs out of the fixed noise floor. Also added inline rationale for the `FIXTURE_SIZE = 800` and `PERF_ITERATIONS = 20` constants. Refs #12729. --- .../src/methods/aclEntry.parity.spec.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/data-schemas/src/methods/aclEntry.parity.spec.ts b/packages/data-schemas/src/methods/aclEntry.parity.spec.ts index cc6d43c979..2a383fe2df 100644 --- a/packages/data-schemas/src/methods/aclEntry.parity.spec.ts +++ b/packages/data-schemas/src/methods/aclEntry.parity.spec.ts @@ -27,7 +27,9 @@ let mongoServer: MongoMemoryServer; let AclEntry: mongoose.Model; let methods: ReturnType; +/** Enough entries to exercise real query planning without bloating CI runtime. */ const FIXTURE_SIZE = 800; +/** Enough iterations for a reasonably stable median; still finishes in <2s total. */ const PERF_ITERATIONS = 20; beforeAll(async () => { @@ -356,7 +358,13 @@ describe('ACL $bitsAllSet vs $in parity (issue #12729)', () => { /** Sanity check: the new path should not be dramatically slower. A 3x * multiplier catches catastrophic regressions (e.g. missing index use) * without flaking on normal CI variance. */ - expect(currentMs).toBeLessThan(legacyMs * 3 + 50); + /** + * Multiplicative-dominant guard: tolerate up to 5× regression or 50ms + * absolute, whichever is larger. The `legacyMs * 3 + 50` form we had + * previously was dominated by the additive term at sub-ms latencies and + * would have let a 50× regression pass silently. + */ + expect(currentMs).toBeLessThan(Math.max(legacyMs * 5, 50)); }); test('findPublicResourceIds: $bitsAllSet vs $in', async () => { @@ -394,7 +402,13 @@ describe('ACL $bitsAllSet vs $in parity (issue #12729)', () => { `[perf] findPublicResourceIds — legacy $bitsAllSet: ${legacyMs.toFixed(2)}ms, ` + `current $in: ${currentMs.toFixed(2)}ms (median of ${PERF_ITERATIONS} runs, ${FIXTURE_SIZE} entries)`, ); - expect(currentMs).toBeLessThan(legacyMs * 3 + 50); + /** + * Multiplicative-dominant guard: tolerate up to 5× regression or 50ms + * absolute, whichever is larger. The `legacyMs * 3 + 50` form we had + * previously was dominated by the additive term at sub-ms latencies and + * would have let a 50× regression pass silently. + */ + expect(currentMs).toBeLessThan(Math.max(legacyMs * 5, 50)); }); }); });