refactor(chunk): remove the unused chunk_overlap option
What does this MR do and why?
This MR removes the chunk_overlap option from chunk mode. Nothing applies it: the code chunkers only check it against the chunk size, the size chunker that read it is gone, and GitLab never sends it. Chunk mode rejects unknown options, so a caller that still sends it now gets an error instead of an option that does nothing. Indexing does not change.
Related issues
Closes #210 (closed)
Testing
A new decoding test case asserts that chunk_overlap is refused as an unknown field; it failed before the change and passes with it. The chunk mode packages pass with -race on Go 1.26.7 and 1.27.3, and make golangci-lint at the pinned 2.11.3 reports 0 issues.
Performance analysis
The change removes one comparison made when the chunker is created, once per run, so indexing does the same work as before.
- This merge request does not introduce a performance regression. If a regression is expected, explain why.
Details: what goes, why at once, the alternative, checks
What goes.
ChunkOverlapinOptions(thechunk_overlapkey of--options) and inchunker.ChunkOptions, and the line ofcreateChunkerthat copied one into the other.- The check in
code.Newandcode.NewPreBertthat refused an overlap not less than the chunk size. It was the option's only reader: neither constructor passes the overlap to gitlab-code-parser, whose split-code chunkers take only the chunk size (code/chunker.go#L25-68). - In
TestCreateChunker, the two cases that tested that check, andChunkOverlap: 100in the other five. - In the README, the entry in the index options list, the row in the options table, and the key in examples 1, 3 and 4.
After the change, git grep -n -i overlap -- ':!CHANGELOG.md' finds only the new test case.
What is added. A case in TestOptionsDecoding that decodes {"project_id": 123, "chunk_size": 1000, "chunk_overlap": 128} with unknown fields disallowed, as Run does (chunk.go#L144-149), and asserts that the error names unknown field "chunk_overlap". Without the rest of the change it fails with An error is expected but got nil.
Why at once. The cleanup was proposed in the review of !972 (merged), and the issue asked whether to remove the option at once or to keep accepting it for a release first. I chose removal at once because:
- GitLab's code indexer sends
chunk_strategyandchunk_sizeon top of the base options, and no overlap (indexer.rb#L98-109, indexer_base.rb#L50-57), and the collection options schema it reads them from allows no overlap key (ai_active_context_collection_options.json#L5-43). A code search of gitlab-org/gitlab forchunk_overlapfinds nothing. - GitLab pins the indexer version it runs in
GITLAB_ELASTICSEARCH_INDEXER_VERSION(5.15.0 on master today), so the two move together. - A caller outside GitLab that still sends the key fails at once with
parse options: json: unknown field "chunk_overlap", rather than indexing with a setting that silently does nothing.
The alternative. If you would rather give such callers a release to drop the key, the field can stay in Options, accepted and ignored, with a comment saying so, and go in a later release. That is a small commit on top of this one, and I can push it. I did not mark the commit as a breaking change, since GitLab never sends the option; if you want it marked, the next weekly release becomes a new major version.
Checks with the change at 20ba8e85 on main at ac7a9aba, on Linux amd64 with Go 1.26.7 (from .tool-versions) unless named, and libicu-dev 76.1:
go mod tidy(no change),make format(no file changed),./scripts/check-go-format.sh,make build,go vet ./...,./scripts/check-tool-versions.shand./scripts/check-go-mod-version.sh.go test -race -count=1 ./internal/mode/chunk/...with Go 1.26.7 and 1.27.3: every package passes.go test -run '^$' -bench BenchmarkChunker ./internal/mode/chunk/chunker/: thecode_bytesandcode_pre_bertcases run.make golangci-lintwith golangci-lint 2.11.3:0 issues.make testandmake coverwithout Elasticsearch or Gitaly: every package passes exceptTestBulkSizeTrackingininternal/mode/advanced/elastic, which posts to Elasticsearch at 127.0.0.1:9200 and gets connection refused. It fails the same way without this change, and that package and its tests import nothing underinternal/mode/chunk(go list -deps -test). The tests of the nestedthird_party/icumodule pass with-race.- commitlint with the project's
.commitlintrc.ymlon the commit and on this title: 0 problems.
Not run: the integration tests that need make test-infra. None of them sets chunk_overlap.