Skip to content

perf: cache sorted page tree and precompute nav map#53

Merged
rsbh merged 1 commit intomainfrom
perf/cache-page-tree-and-nav
May 8, 2026
Merged

perf: cache sorted page tree and precompute nav map#53
rsbh merged 1 commit intomainfrom
perf/cache-page-tree-and-nav

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented May 8, 2026

Summary

  • Cache sorted page tree after first computation — getPageTree() no longer re-sorts on every call
  • Precompute Map<url, {prev, next}> nav map — getPageNav() is now O(1) map lookup instead of flatten + linear search per request
  • invalidate() clears all caches (source, tree, nav map)

Test plan

  • All 88 tests pass
  • API responds in ~3ms with caching vs repeated tree rebuilds
  • Verify client-side page navigation works in browser
  • Verify content invalidation (HMR) still refreshes nav correctly

🤖 Generated with Claude Code

Tree sorting and nav computation ran on every /api/page request.
Now cached after first call — getPageNav is O(1) map lookup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment May 8, 2026 4:43am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Warning

Rate limit exceeded

@rsbh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 38 minutes and 30 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 098b0bbc-0b72-411e-a7bf-c00a8175c1b8

📥 Commits

Reviewing files that changed from the base of the PR and between 9e86794 and fa41af4.

📒 Files selected for processing (2)
  • packages/chronicle/src/lib/source.ts
  • packages/chronicle/src/server/entry-server.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/cache-page-tree-and-nav

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 and usage tips.

@rsbh rsbh merged commit ed3d944 into main May 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants