Skip to content
quarry View Ticket
Login

View Ticket

2026-09-24
00:52 • Ticket [fbe8dbfcc2] Fleet surfaces are O(repos) and will not survive thousands of stores status still Open with 1 other change artifact: be5e7068dc user: zeitgeist
2026-09-12
15:57 • Ticket [fbe8dbfcc2]: 2 changes artifact: fbc148010a user: zeitgeist
2026-08-19
12:10 • Ticket [fbe8dbfcc2]: 1 change artifact: 8285058936 user: dmestas
11:04 • Ticket [fbe8dbfcc2]: 2 changes artifact: 9dd65c53c0 user: dmestas
2026-08-18
19:56 • New ticket [fbe8dbfcc2]. artifact: 77a8b7471e user: dmestas

Fleet surfaces are O(repos) and will not survive thousands of stores

Openfbe8dbfcc230b567da3d6a8da157cc68961d3761Created 104.2 days agoUpdated 67.9 days ago
Description2026-08-18 19:56:50
Everything fleet-wide today walks every repository. At 23 stores that is invisible; it is linear, so it is a wall rather than a slope.

Measured now, and the naive extrapolation to 10,000 stores:

| surface | 23 repos | ~10,000 | |---|---|---| | `repo.list` | 42 ms | ~4 s | | `people.list` | 8 ms | ~6.5 s | | `search.all` | 415 ms | ~40 s |

`search.all` is the worst because each repository is a separate SQLite file and a separate FTS query. It is also the one with a hard resource floor: 10,000 open database handles.

## What has to change

1. **Paging, everywhere.** `repo.list` returns every repository and the landing page renders all of them. It needs a cursor and a page size, and the fleet SSE stream has to page with it or a repaint re-sends the whole listing. 2. **Never open every index to answer a fleet question.** `people.list` and the tab counts should read a fleet-level rollup in the forge OLTP, refreshed on ingest, rather than fanning out per request. The per-repo `contributor` table is already the right shape to roll up from. 3. **Search needs a different mechanism, not a bigger fan-out.** Fan-out was the honest choice at this size and it stays correct, but past roughly 500–1,000 stores it has to become one shared index. That is the point at which the contentless-FTS work becomes worth doing too, since the shared index is where the duplicated `search_doc` text would otherwise be paid for again. 4. **Bound the handles.** An index handle per served repository is a file descriptor per repository held open forever. That needs an LRU of open indexes with the rest closed.

## Order

Paging first — it is the only one a reader notices immediately, and it is contained. The rollup second. The shared search index last, because it is the one that changes the architecture rather than the queries, and it should be done with a real corpus to measure against rather than speculatively.

2026-09-12 15:57:54

Re-read 2026-09-12. The analysis still holds: repo.list takes a Limit but has no cursor and still walks every store to build the list before capping it, and people.list still fans out over Repos.Names(). Three things have changed around it, though.

  1. Item 1's mechanism now exists as a worked example. The forum thread list was the same shape of wall — it rendered every thread — and now pages with a keyset cursor (activity DESC, root ASC) plus a separate count query for the total, one row over the page so 'is there a next page' is answered by what came back. Measured on fossil's forum: 26,736 KB and 264 ms became 393 KB and 55 ms. Worth copying rather than re-deriving for repo.list. Note the measurement surprise: the two SQL queries cost 72 ms together, so the wall was MARKUP (222,884 rect elements from per-thread sparklines and identicons), not the query. Any paging work here should measure which half it is before optimising.

  2. Item 4 got its precondition. Index.Close() now waits for the rewarms it started instead of closing the database underneath them — an LRU of open indexes has to be able to close one while background work is in flight, and until now that was a use-after-close.

  3. One cost went UP, which the ticket should know: search.all now also searches a bound forum companion (RFC 0015), so the fan-out is one extra index per bound pair, not per repository. Companion stores are otherwise filtered out of the dashboard listing and folded into their parent's facet, so a bound pair is one project to a reader and two indexes to the fan-out.

The 23-store measurements in the table are also now stale in composition rather than in kind: pkgsrc was added (218,590 records, 1.1 GB of index) and it is the store that would dominate any per-repo fan-out timing.