Loading workspace insights... Statistics interval
7 days30 daysLatest CI Pipeline Executions
1cd3483a perf: optimize lru-cache.ts
# LRU Cache Optimization Results
## BEFORE
State: test/benchmark support changes applied, implementation stashed to baseline.
### Tests
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/lru.test.ts`: failed, 1 failed / 13 total.
- Failure: `updates existing entries without evicting when full`, expected `cache.get('a')` to be `1`, received `undefined`.
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache`: failed, 1 failed / 1104 total.
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:types --outputStyle=stream --skipRemoteCache`: passed.
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:eslint --outputStyle=stream --skipRemoteCache`: passed with 20 existing warnings.
### Performance
Command: `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:perf --outputStyle=stream --skipRemoteCache -- tests/lru-cache.bench.ts`
| Case | hz | mean | rme | samples |
| --- | ---: | ---: | ---: | ---: |
| newest hit | 18,518.89 | 0.0540 | +/-0.58% | 9,260 |
| rotating hit | 13,741.92 | 0.0728 | +/-3.08% | 6,871 |
| update newest while full | 17,309.32 | 0.0578 | +/-0.67% | 8,655 |
| update oldest while full | 17,448.76 | 0.0573 | +/-1.65% | 8,725 |
| update rotating entries while full | 9,113.98 | 0.1097 | +/-0.50% | 4,557 |
| miss-heavy get | 78,647.37 | 0.0127 | +/-0.73% | 39,324 |
| insert churn | 14,705.09 | 0.0680 | +/-3.13% | 7,353 |
| mixed workload | 41,227.14 | 0.0243 | +/-0.25% | 20,614 |
### Bundle Size
Command: `CI=1 NX_DAEMON=false pnpm nx run @benchmarks/bundle-size:build --outputStyle=stream --skipRemoteCache --skipNxCache -- --scenario react-router.minimal >/tmp/lru-before-targeted-bundle.log 2>&1 && pnpm benchmark:bundle-size:query --id react-router.minimal`
- `react-router.minimal gzip=89421 initial=89281 raw=280786 brotli=77765`
## AFTER
State: test/benchmark support changes plus optimized LRU implementation applied.
### Tests
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/lru.test.ts`: passed, 13 passed / 13 total.
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache`: passed, 1101 passed / 3 expected fail / 1104 total.
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:types --outputStyle=stream --skipRemoteCache`: passed.
- `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:eslint --outputStyle=stream --skipRemoteCache`: passed with 20 existing warnings.
### Performance
Command: `CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:perf --outputStyle=stream --skipRemoteCache -- tests/lru-cache.bench.ts`
| Case | hz | mean | rme | samples |
| --- | ---: | ---: | ---: | ---: |
| newest hit | 19,796.85 | 0.0505 | +/-0.43% | 9,899 |
| rotating hit | 14,971.94 | 0.0668 | +/-0.44% | 7,486 |
| update newest while full | 19,253.35 | 0.0519 | +/-1.03% | 9,627 |
| update oldest while full | 18,284.35 | 0.0547 | +/-3.18% | 9,143 |
| update rotating entries while full | 14,969.14 | 0.0668 | +/-0.92% | 7,485 |
| miss-heavy get | 78,455.30 | 0.0127 | +/-0.26% | 39,228 |
| insert churn | 14,950.34 | 0.0669 | +/-4.60% | 7,476 |
| mixed workload | 38,459.24 | 0.0260 | +/-2.41% | 19,230 |
### Performance Comparison
| Case | BEFORE hz | AFTER hz | hz delta | BEFORE mean | AFTER mean | mean delta |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| newest hit | 18,518.89 | 19,796.85 | +6.90% | 0.0540 | 0.0505 | -6.48% |
| rotating hit | 13,741.92 | 14,971.94 | +8.95% | 0.0728 | 0.0668 | -8.24% |
| update newest while full | 17,309.32 | 19,253.35 | +11.23% | 0.0578 | 0.0519 | -10.21% |
| update oldest while full | 17,448.76 | 18,284.35 | +4.79% | 0.0573 | 0.0547 | -4.54% |
| update rotating entries while full | 9,113.98 | 14,969.14 | +64.24% | 0.1097 | 0.0668 | -39.11% |
| miss-heavy get | 78,647.37 | 78,455.30 | -0.24% | 0.0127 | 0.0127 | 0.00% |
| insert churn | 14,705.09 | 14,950.34 | +1.67% | 0.0680 | 0.0669 | -1.62% |
| mixed workload | 41,227.14 | 38,459.24 | -6.71% | 0.0243 | 0.0260 | +7.00% |
Notes: `update rotating entries while full` improves materially because the old implementation evicted before checking existing entries. `mixed workload` regressed in this run and has moderate noise (`AFTER rme +/-2.41%`), so treat as directional.
### Bundle Size
Command: `CI=1 NX_DAEMON=false pnpm nx run @benchmarks/bundle-size:build --outputStyle=stream --skipRemoteCache --skipNxCache -- --scenario react-router.minimal >/tmp/lru-after-targeted-bundle.log 2>&1 && pnpm benchmark:bundle-size:query --id react-router.minimal && pnpm benchmark:bundle-size:diff --baseline /var/folders/6f/2t42ntqs4yv4h6qwzbh5pmcm0000gn/T/opencode/lru-base-current.json --id react-router.minimal`
- `react-router.minimal gzip=89407 initial=89268 raw=280685 brotli=77653`
- Diff vs BEFORE: `gzip -14`, `initial -13`, `raw -101`, `brotli -112`.