Skip to content

rangeread: find each span's extents by binary search - #7

Merged
Seif Lotfy (seiflotfy) merged 1 commit into
mainfrom
brush-up-2
Nov 10, 2026
Merged

Seif Lotfy (seiflotfy) merged 1 commit into
mainfrom
brush-up-2

Conversation

@seiflotfy

Copy link
Copy Markdown
Member

Follow-up to #6. rangeread.Read scanned every extent for every planned span, O(spans × extents). It now sorts the extents once and binary-searches the ones a span can overlap (ReadPlanned keeps its signature and behaviour).

  • BenchmarkReadManyExtents (10,000 × 1 KiB extents, 8 KiB stride, mem, -count=6, benchstat p=0.002): 122.7ms → 43.6ms (-64%). At 100–1,000 extents there is no measurable change. Against a real object store the network cost dominates, so this matters only for very many extents per Read.
  • No format change.
  • Test: randomized check that the index never skips an overlapping extent (nested/overlapping extents, several objects); it fails if the running-max reach is removed.

Not done: fs listing. A page already costs only the directory it touches. Paging a flat 5,000-file directory in pages of 500 is about 3 ms per page (re-read and sort of that directory). Removing that needs a directory cursor or index, a design change for a modest gain, so I left it.

Verified: gofmt, vet, staticcheck, go test -race ./....

@seiflotfy
Seif Lotfy (seiflotfy) merged commit f1efaed into main Nov 10, 2026
4 checks passed
@seiflotfy
Seif Lotfy (seiflotfy) deleted the brush-up-2 branch November 10, 2026 04:20
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.

1 participant