Skip to content

refactor(storage): load index registry once in IndexReader constructor - #568

Open
eguguchkin wants to merge 2 commits into
mainfrom
0-index-reader-no-cache
Open

eguguchkin wants to merge 2 commits into
mainfrom
0-index-reader-no-cache

Conversation

@eguguchkin

@eguguchkin eguguchkin commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

The index registry (the block-header table of an index file) was previously loaded lazily through a cache.Cache[[]byte], so every BlocksCount() / GetBlockHeader() call took a cache lookup guarded by a mutex. On the frac-load path these calls are frequent and concurrent across readers, and mutex contention on the shared cache entry made them measurably expensive.

This PR loads the registry once in NewIndexReader into a plain registry []byte field. Since the registry is immutable for the lifetime of the reader, reads are now lock-free — the mutex is paid once per reader instead of on every access.

As a side effect, BlocksCount() becomes infallible (int instead of (int, error)), so error handling disappears from frac/sealed_loader.go and frac/sealed/token/table_loader.go.


  • I have read and followed all requirements in CONTRIBUTING.md;
  • I used LLM/AI assistance to make this pull request;

If you have used LLM/AI assistance please provide model name and full prompt:

Model: {{model-name}}
Prompt: {{prompt}}

@codecov-commenter

codecov-commenter commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.21%. Comparing base (961ed42) to head (f2cd118).

Files with missing lines Patch % Lines
storage/index_reader.go 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
- Coverage   79.21%   79.21%   -0.01%     
==========================================
  Files         249      249              
  Lines       18844    18828      -16     
==========================================
- Hits        14927    14914      -13     
+ Misses       3917     3914       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eguguchkin
eguguchkin requested review from dkharms and forshev and removed request for dkharms October 8, 2026 14:13

This branch has not been deployed

No deployments
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.

4 participants