mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-05-14 00:19:40 +00:00
🧪 test: tighten parity perf guard and document fixture constants
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.
This commit is contained in:
parent
114559bce1
commit
21852acc58
1 changed files with 16 additions and 2 deletions
|
|
@ -27,7 +27,9 @@ let mongoServer: MongoMemoryServer;
|
|||
let AclEntry: mongoose.Model<t.IAclEntry>;
|
||||
let methods: ReturnType<typeof createAclEntryMethods>;
|
||||
|
||||
/** 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));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue