Skip to content

feat: Fix chunk source line counting, add semble-only benchmark option - #266

Merged
Pringled merged 5 commits into
mainfrom
fix-chunk-source-line-counting
Sep 11, 2026
Merged

feat: Fix chunk source line counting, add semble-only benchmark option#266
Pringled merged 5 commits into
mainfrom
fix-chunk-source-line-counting

Conversation

@Pringled

Copy link
Copy Markdown
Member

chunk_source counted newlines in source[: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 uses bisect_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-only option to the benchmarks for easier reruns when changes just affect semble, and reran the benchmarks and updated our numbers.

…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

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/semble/chunking/chunking.py 100.00% <100.00%> (ø)
src/semble/version.py 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stephantul stephantul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHO WROTE THIS!? (me)

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The implementation appears safe to merge, with two non-blocking benchmark reproducibility and reporting issues to correct.

Reviews (1) · Last reviewed commit: "docs: update semble index time after the..."

Comment thread benchmarks/speed_benchmark.py
Comment thread benchmarks/README.md
@Pringled
Pringled merged commit 3bcefb7 into main Sep 11, 2026
16 checks passed
@Pringled
Pringled deleted the fix-chunk-source-line-counting branch September 11, 2026 09:44
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