Skip to content

perf(frag_reuse): cache stable-partition row-map chunks - #9252

Merged
LuQQiu merged 1 commit into
mainfrom
lu/fri-rowmap-cache
Oct 5, 2026
Merged

LuQQiu merged 1 commit into
mainfrom
lu/fri-rowmap-cache

Conversation

@LuQQiu

@LuQQiu LuQQiu commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Caches stable-partition row-map labels to reduce repeated storage reads while indexes still rely on query-time FRI translation.

Previously, the mapping object was cached but its labels were reread for different index pages and later queries. Builds on #9187; no format or translation-semantics changes.

What changes

  • Chunk caching: store 32 mapping blocks per chunk in the existing session index cache, keyed by transition and chunk. Reuse immutable labels across queries and snapshots; deduplicate concurrent loads.
  • Small-cache fallback: when the cache cannot hold a chunk, read only requested adjacent blocks. Sparse requests do not read intervening gaps.
  • Batch reuse: reuse loaded labels and discover each contiguous run once, avoiding quadratic lookahead.

Tradeoffs and evidence

A default chunk contains about 2M labels, requiring approximately 4 MiB plus overhead. It shares the cache budget with index state, so an undersized cache can still thrash.

In the recorded 20M-row NVMe benchmark, cold row-map reads fell from 10,440 to 17 and bytes from 419 MB to 12.9 MB. Local QPS remained similar; object-storage throughput improvement still requires measurement.

Tests

Covers cached/uncached equivalence, zero/sub-chunk capacity, sparse reads, multi-chunk maps, and duplicates/deletions. A 300-block case verifies 299 lookahead steps instead of 44,850.

@github-actions

Copy link
Copy Markdown
Contributor

ACTION NEEDED
Lance follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

For details on the error please inspect the "PR Title Check" action.

@github-actions github-actions Bot added the A-index Vector index, linalg, tokenizer label Sep 15, 2026
@LuQQiu LuQQiu changed the title exploration(frag_reuse): cache stable-partition row-map chunks in the index cache perf(frag_reuse): cache stable-partition row-map chunks Sep 15, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 2442bd1 to 8ff878a Compare September 15, 2026 22:07
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 8ff878a to 20b91b2 Compare September 15, 2026 23:11
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 20b91b2 to 91eff7d Compare September 20, 2026 18:18
@LuQQiu
LuQQiu added this pull request to stack #9137 September 20, 2026 18:53
@LuQQiu
LuQQiu marked this pull request as ready for review September 20, 2026 18:55
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 20, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 91eff7d to 806e29c Compare September 22, 2026 01:37
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 806e29c to adcb452 Compare September 22, 2026 23:24
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 22, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 22, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from adcb452 to fefb1bb Compare September 23, 2026 01:12
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from fefb1bb to 0f434b0 Compare September 23, 2026 02:35
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 23, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from fe3311c to 6514fb5 Compare September 24, 2026 00:31
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 6514fb5 to dff171c Compare September 24, 2026 17:35
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from dff171c to 6283ce9 Compare September 24, 2026 20:04
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 24, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 24, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 6283ce9 to aa29da4 Compare September 24, 2026 21:54
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 24, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 24, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from aa29da4 to 3b836e4 Compare September 24, 2026 22:16
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from 3b836e4 to e1a2e50 Compare September 25, 2026 00:14
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 25, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Sep 25, 2026
@LuQQiu
LuQQiu force-pushed the lu/fri-rowmap-cache branch from e1a2e50 to 83a6a83 Compare September 25, 2026 10:33
lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Gate recommendation: approve with a non-blocking risk.

The new run-boundary lookahead removes the quadratic scan for contiguous requests while preserving sparse low-cache reads. The chunk cache remains a sound way to avoid repeated row-map I/O without changing the file format.

Decoded chunks share the index-cache budget with index partitions. The reported 64 MiB experiment thrashed when the combined working set did not fit, so size that cache before prewarming on constrained deployments. Remote-object-store throughput remains unmeasured.

This PR remains stacked on #9187, whose current head is this PR’s base. Land or rebase after that prerequisite.

@LuQQiu

LuQQiu commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

The linux-build and linux-arm failures here are the four rest::tls tests in lance-namespace-impls (test_incomplete_initial_load_is_retried, test_malformed_ca_certificate_is_dropped_on_its_own, test_rotation_is_picked_up_once_the_interval_elapses::case_1_interval_elapsed, test_unusable_rotated_material_keeps_client), added by #8456; this stack does not touch that crate, and main fails the same four tests in the same two jobs on its own tip: https://github.com/lance-format/lance/actions/runs/36194697954 (2f5d4fb) and https://github.com/lance-format/lance/actions/runs/36170893444 (0aa3d53).

A query that translates addresses through a tagged fragment-reuse history
re-read the row-map label blocks on every call. Cache the labels in the
session index cache in ~4 MiB chunks (32 blocks, keyed by transition
fingerprint and chunk index), so each part of the row map is read at most
once. The chunk unit keeps the entry count small (~48 at 100M rows, ~477 at
1B) while making each cold miss one large sequential range read. On a
20M-row fixture this cuts cold _fri reads from ~10,440 to ~17 per query.
Cache-off behavior is byte-identical (a regression test compares cached
and uncached point, batch and sweep translations).

When the cache cannot retain a chunk, labels are read per request: a run
of adjacent blocks is one range read, a point lookup reads exactly its
block, and a sparse batch never reads a block it does not touch. The end
of a contiguous run is discovered once per run and reused for every block
inside it, so a request touching B consecutive blocks costs B - 1 lookahead
steps instead of B * (B - 1) / 2.

Claude-Session: https://claude.ai/code/session_01DgAshYD7wVzPVdjXRuWPPs

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants