Skip to content

Apply remaining #418 performance optimizations on top of #417#419

Merged
kibertoad merged 2 commits into
mainfrom
merge-418-optimizations
Jul 3, 2026
Merged

Apply remaining #418 performance optimizations on top of #417#419
kibertoad merged 2 commits into
mainfrom
merge-418-optimizations

Conversation

@kibertoad

Copy link
Copy Markdown
Owner

Rebases the still-relevant parts of #418 onto current main, which now includes #417.

The two bug fixes #418 originally carried already landed via #417:

  • falsy value caching in InMemoryCache.getMany / InMemoryGroupCache.getManyFromGroup (undefined check instead of a truthy check)
  • InMemoryGroupCache reads no longer inserting empty groups into the LRU

So this keeps only the performance and code-quality changes from #418:

  • AbstractFlatCache / AbstractGroupCache: resolve the cache key once and reuse it across getInMemoryOnly / getAsyncOnly / get (new private *Resolved methods) instead of re-resolving per call. Layered on top of Fix race conditions and correctness issues in caching layers #417's write-back fencing.
  • getMany merge appends async results into the in-memory result array in place (always freshly allocated) instead of spreading into a new array.
  • Loader / GroupLoader: build cache entries with an explicit loop, merge cached and loaded values with concat (cachedValues may be owned by a user-implemented async cache), hoist the dataSource local.
  • AbstractRedisCache: precompute keyPrefix. RedisGroupCache: precompute the group index prefix and per-group entry prefix.
  • unique(): early return for arrays of 0-1 elements.

Regression tests added: falsy-caching path at the Loader / GroupLoader level, and the unique() early return.

tsc --noEmit is clean and the full suite (330 tests, Redis included) passes. Biome reports only the 8 formatting diagnostics already present on main; this change adds none.

Supersedes #418.

The bug fixes originally bundled in #418 (falsy value caching in
InMemoryCache/InMemoryGroupCache getMany, and reads no longer inserting
empty groups into the LRU) already landed via #417, so only the
performance and code-quality changes remain:

- AbstractFlatCache/AbstractGroupCache: resolve the cache key once and
  reuse it across getInMemoryOnly/getAsyncOnly/get instead of resolving
  it multiple times per call
- getMany merge appends async results into the in-memory result array in
  place (it is always freshly allocated) rather than spreading into a new
  array
- Loader/GroupLoader: build cache entries with an explicit loop, merge
  cached and loaded values with concat (cachedValues may be owned by a
  user-implemented async cache), and hoist the dataSource local
- AbstractRedisCache: precompute keyPrefix; RedisGroupCache: precompute
  the group index prefix and the per-group entry prefix
- unique(): early return for arrays of 0-1 elements

Regression tests for the falsy-caching path at the loader level and for
the unique() early return are included.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kibertoad, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1b01811-9880-4646-9464-255d3bef0a89

📥 Commits

Reviewing files that changed from the base of the PR and between 3a0826b and 6528633.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • lib/AbstractFlatCache.ts
  • lib/AbstractGroupCache.ts
  • lib/GroupLoader.ts
  • lib/Loader.ts
  • lib/redis/AbstractRedisCache.ts
  • lib/redis/RedisGroupCache.ts
  • lib/util/unique.spec.ts
  • lib/util/unique.ts
  • package.json
  • pnpm-workspace.yaml
  • test/GroupLoader-main.spec.ts
  • test/Loader-main.spec.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch merge-418-optimizations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kibertoad kibertoad added the patch label Jul 3, 2026
@kibertoad kibertoad merged commit 3682d1c into main Jul 3, 2026
6 checks passed
@kibertoad kibertoad deleted the merge-418-optimizations branch July 3, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant