feat: Fix chunk source line counting, add semble-only benchmark option - #266
Merged
Conversation
…fsets chunk_source counted newlines in source[:offset] for every chunk, copying and rescanning the file prefix each time, so chunking was quadratic in file size. Record newline offsets once and use bisect_left, which returns the same count. On FastAPI + pydantic (1834 files, 18873 chunks) the output is identical to the previous implementation; chunking time drops from 1623ms to 1128ms overall and from 132ms to 33ms on the largest (358KB) file. Claude-Session: https://claude.ai/code/session_01N5WnCfeaj66TgZTbqm2Zew
Lets semble's index time and query latency be re-measured without re-running the slow baselines (CodeRankEmbed alone takes minutes). Claude-Session: https://claude.ai/code/session_01N5WnCfeaj66TgZTbqm2Zew
Re-measured with `speed_benchmark --semble-only` at eb6676a (median of the saved runs; two runs taken under background load were ~430 ms and discarded). Semble's mean cold-start index time drops from 344 ms to 306 ms, so the CodeRankEmbed index-time claim goes from ~340x to ~380x. Query p50 stays at 0.91 ms: search is unchanged by this branch, and the re-run's 0.95 ms was machine noise. Regenerated the cold speed plot. Claude-Session: https://claude.ai/code/session_01N5WnCfeaj66TgZTbqm2Zew
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
stephantul
approved these changes
Sep 11, 2026
stephantul
left a comment
Contributor
There was a problem hiding this comment.
WHO WROTE THIS!? (me)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chunk_sourcecounted newlines insource[:offset]for every chunk, re-scanning the file prefix each time, so chunking was quadratic in file size. It now records newline offsets once and usesbisect_left, which gives the same line numbers but much faster. This helps mostly on large files which are ~30% faster to index. On average our indexing speed goes up by ~9%.Also added a
--semble-onlyoption to the benchmarks for easier reruns when changes just affect semble, and reran the benchmarks and updated our numbers.