perf(metrics): Increase output token counting chunk size from 100KB to 200KB#1415
perf(metrics): Increase output token counting chunk size from 100KB to 200KB#1415
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe pull request increases the character-per-chunk threshold in the token counting metrics calculation from 100,000 to 200,000 characters. This adjusts how content is segmented for parallel token counting operations while maintaining the same control flow and error handling approach. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
⚡ Performance Benchmark
Details
Historyba4b0b0 fix(metrics): Use 'characters' instead of 'KB' in chunk size comments
dd94bfb perf(metrics): Increase output token counting chunk size from 100KB to 200KB
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1415 +/- ##
=======================================
Coverage 87.26% 87.26%
=======================================
Files 117 117
Lines 4420 4420
Branches 1021 1021
=======================================
Hits 3857 3857
Misses 563 563 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Review:
|
Review Update:
|
…o 200KB Benchmarks show 200KB chunks are optimal for output token counting, reducing worker round-trips while maintaining good parallelism across available CPU cores. For a 3.9MB output (typical large repo), this reduces chunks from 39 to 20, saving ~46ms per run due to fewer structured-clone round-trips. Benchmark results (repomix self-pack, 996 files, 3.8M chars, 5 runs): - Before (100K chunks): 1384ms median - After (200K chunks): 1293ms median - Improvement: ~91ms = ~6.6% Combined with existing batch IPC optimization, total improvement vs baseline is ~156ms = ~10.8%. https://claude.ai/code/session_01NjmXXUzBrB2oe4FD82NpGe
JS strings use UTF-16 encoding where character count != byte count. Use 'K characters' for technical accuracy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ba4b0b0 to
9e19916
Compare
Increase
TARGET_CHARS_PER_CHUNKfrom 100KB to 200KB for output token counting.200KB chunks reduce worker round-trips while maintaining good parallelism across available CPU cores. For a ~4MB output (typical large repo), this reduces chunks from 39 to 20.
Benchmark (repomix self-pack,
node bin/repomix.cjs, 5 runs):Checklist
npm run testnpm run lint🤖 Generated with Claude Code