[Canonical HTML page](https://githits.com/blog/why-indexing-small-changes-is-expensive/)

[Back to blog](/blog.md)

![A grid of gray wireframe index blocks linked to a yellow cluster and a magenta cluster of new blocks](/_astro/cover.BbUjPXsj_2jqqlW.webp)

November 23, 2026 · 9 min read

# Why small code changes are expensive to index

How a new index format made indexing a small change between versions almost three times faster.

Our goal at GitHits is to index all of the world’s open source code. We index every version our users need. That is one index per repository per version, so each index has to be fast to build and small to store.

A new version usually differs from one we’ve already indexed by a handful of files. We build a new index from the nearby version’s index, which stays unchanged, redoing only what changed. If three files changed, an incremental build should cost about as much as indexing three files.

Most of these builds were already fast. In the two weeks from late October to November 12, incremental builds across more than 22,000 repositories took about 10 seconds at the median. Builds on repositories with 10,000 or more files were just under 10% of those builds and took 46 seconds at the median. Waiting for a version to be indexed is still the delay users notice most, so I kept looking for ways to make these builds faster.

Getting the cost close to the size of the change took almost three months, because a small change rarely stays small. A changed function matters to every file that calls it and to the files that call those. Search scores depend on counts across the whole repository. We found most of the ways a change spreads by trying a design on a real repository and watching it fail.

The result is a new index format. On the same commits, an incremental build now takes 64% less time, which makes it almost three times as fast. Very large repositories gain the most. Every repository has used the new format since November 18.

## What a version holds and why reuse saved so little

Each index covers one version of one repository, a single commit or tag, so an agent can look up the exact version a project depends on. For each version we store six kinds of data. File contents are stored once, keyed by a hash of their content. Every version that contains the same file shares them. Symbols record names, kinds, signatures and locations. The call and import graph records which function calls which, how a name in one file resolves to its definition in another and which external packages the code uses. Flow data describes control and data flow inside each function. A ranked text search index covers code and Markdown. An exact text index answers grep-style queries that must find every occurrence.

These kinds of data don’t react to a change in the same way. File contents, symbols and flow data come from a single file, so an unchanged file gives the same answer as before. Most of the exact text index is built file by file too. The call graph depends on the whole repository, because resolving a name means looking at every file that could define it. Ranked search does too, because its scores use repository-wide counts. Even the data that comes from one file ends up in structures that cover the whole version, such as symbol lookup tables, edge lists and search structures. That split, between what belongs to one file and what belongs to the whole version, decides how much an incremental build can reuse.

The previous format already skipped parsing files whose content hadn’t changed. That should have been most of the job. It wasn’t. Every build, however small the change, still rebuilt the whole-version structures and wrote the version’s index files again as a whole. In one audit, an incremental build on a large repository skipped 78% of its files and still took longer than building from scratch: 243 seconds against 195. Skipping unchanged files saved the parsing but not the work built on top of it.

For each kind of data, we had to find out why it resisted reuse after a small change and what the cheapest way was to make it follow the change.

## An unchanged file can still have a changed answer

A call in file A resolves to a function in file B. If B changes, the answer for A can change even though A didn’t. Ranked search has the same problem in another form. Its scores depend on repository-wide counts, such as how many files contain a word. So one changed file shifts the score of every other file. An incremental build has to match a fresh build, so none of this can drift.

The obvious approach is to record what depends on what and redo only the affected parts. We spent the most time here. Most of it went into designs we threw away.

For the call graph, our first design kept a record for every link between a name and its definition. The record listed what that link depended on. To decide what to redo, every incremental build read those records back from the nearby version’s index. That reading was slow. On a very large repository the records grew to gigabytes. In one comparison the previous format finished in 600 seconds, while this design hit our 900-second timeout. It was also far too cautious. It often marked over a thousand links for rework when none of them had changed.

A simple experiment ended that design. We kept a small summary of each file and re-ran ordinary name resolution over the whole repository from those summaries. The answers matched a full build exactly. Resolution took seconds even on a very large repository. Resolving every name again in memory was far cheaper than remembering why every name resolved. The time goes into writing results back. So an incremental build writes only the links that differ from the nearby version, often a few hundred out of more than a million.

Ranked search went wrong in a different way. We keep its counts exact with a base, a snapshot of the statistics, plus patches that record each change since. On V8, Chrome’s JavaScript engine, an earlier release of the new format showed what that cost. A fresh build took 49 seconds, but incremental builds of the versions after it took up to 133. Every changed file had to work through all the accumulated patches. The fix stops carrying those patches through every change. When a change is wide enough, the build rebuilds the base once instead. With the fix in place, the next V8 incremental build took 22 seconds.

## When less work didn’t save time

We originally read the whole repository as a single tar archive every time we indexed a version. That sounds wasteful for a small change, so the natural next step was to read only the Git objects we needed. On a large repository it skipped hundreds of megabytes of unchanged files and was still slower than reading the whole archive.

The bytes weren’t where the time went. Some Git hosts take tens of seconds just to start answering a request for individual objects, so what worked was making as few requests as possible. Git records the files in each commit as a tree with a hash for every file. We compare the new commit’s tree with the tree of a nearby version we’ve already indexed and fetch only the file contents that are new.

Writing the index taught us the same thing. The previous format wrote each version’s index files again as a whole. In the new format a version is a small record that lists the pieces it’s made of, so versions share every piece that didn’t change. Pieces no kept version uses any more are garbage-collected after a grace period. On Kubernetes a three-file change went from writing about 740 MB to about 66 MB. Our first test was still slower than the previous format, even though it wrote far fewer bytes. I’d already tried shaving the indexer’s own work and gained almost nothing, while the same build against local disk took under a second. The time was going to round trips to our cloud storage, where every read or write waits for a reply over the network. So we ran reads and writes in parallel and removed duplicate requests.

Reusing more wasn’t always cheaper either. The exact text index should have been the easy case, because most of it depends on single files. Carrying over the finished index for unchanged files gave exact results but needed so much extra data that peak memory rose by more than a third. Rebuilding only the changed files on top of an earlier version we’d already checked was cheaper.

## Sometimes building from scratch is faster

When enough files change, starting over is faster. On a very large repository, an incremental build with about 70,000 changed files took more than twice as long as a fresh build. On the largest repository we index, a similar change ran out of memory.

So before we download any file contents, we compare the new version with the nearby one, using only commit and tree metadata. Very wide changes go to a fresh build. The rule is set from measurements. Applied to 30 days of earlier builds, it would have sent 97 of 20,199 builds to a fresh build.

## Did it pay off?

We ran 485 incremental builds across 211 repositories on both formats. Each pair built the same target commit. We averaged the time ratio within each repository first and then across all repositories with equal weight, so that repositories with many builds don’t dominate. On that measure, an incremental build on the new format takes 64% less time. The median of all 485 builds went from 26 seconds to 11. For very large repositories, it went from 68 seconds to 18.

| Repository size (files)     | Repositories | Build time, new vs previous format |
| --------------------------- | ------------ | ---------------------------------- |
| Small (fewer than 100)      | 35           | 59% less                           |
| Medium (100 to 999)         | 42           | 58% less                           |
| Large (1,000 to 9,999)      | 77           | 60% less                           |
| Very large (10,000 or more) | 57           | 73% less, about 3.7 times faster   |
| All                         | 211          | 64% less                           |

For someone using GitHits, this is the wait before their agent can look up a version we haven’t indexed yet. That wait was already short for most repositories and is now shorter. The biggest change is on very large repositories, where the wait was longest. A three-file change still has to look at the whole repository for some of the indexes. After the experiments with dependency records, I’m not sure building the call graph can be made proportional to the change.

To try it with your own coding agent, run `npx githits@latest init`.

[Engineering](/blog/tag/engineering.md) · [Indexing](/blog/tag/indexing.md) · [Performance](/blog/tag/performance.md)

Juha Litola — Co-founder, Chief Architect

Keep exploring

* [The Solution](/the-solution.md)
* [Documentation](https://docs.githits.com/)
* [Changelog](https://docs.githits.com/changelog/overview)

Get started

## GitHits in one command

Install GitHits or refresh an existing setup with the same command.

`npx -y githits@latest init`

Or connect directly

* [Claude connector](https://claude.ai/directory/githits)
* [ChatGPT plugin](https://chatgpt.com/plugins/plugin_asdk_app_6ae059be511481918e3573fb5885dbb8)
* [Cursor plugin](https://cursor.com/marketplace/githits)

- [Vercel connector](https://vercel.com/connect/githits)
- [Manus connector](https://manus.im/app#connectors/all/connector_8387945e-9687-4a71-86b4-8a220dbd5b6b)
