Skip to content

Proposal: add a Foyer-backed cache for immutable Lance data files #71

Description

@zhangstar333

Motivation

Repeated scans of datasets stored in remote object storage may read the same Lance data ranges multiple times.

Lance's existing Session caches already cover metadata and parsed index structures, but they do not cache data-file contents.

Proposal

Add an optional cache in lance-c backed by Foyer.

The initial implementation would:

  • Cache raw range-read bytes from immutable data/*.lance files.
  • Support memory and disk caching through Foyer.
  • Keep the cache disabled by default and make its capacity and local path configurable.
  • Bypass the cache for manifests, transactions, deletion files, index files, and other objects.
  • Keep the existing Lance Session metadata and index caches unchanged.

Proposed architecture

The cache would be inserted into the object-store range-read path:

flowchart TD
    A[Lance scanner / reader] --> B[ObjectStore cache wrapper]
    B --> C{Path matches data/*.lance?}

    C -->|No| D[Underlying ObjectStore]
    D --> E[Return range bytes]

    C -->|Yes| F[Foyer cache]
    F -->|Cache hit| E
    F -->|Cache miss| G[Underlying ObjectStore]
    G --> H[Populate Foyer]
    H --> E
Loading

Only immutable Lance data files enter Foyer. All other objects bypass it and continue using Lance's existing read path.

Cache responsibilities

flowchart LR
    A[Lance Dataset] --> B[Session metadata cache]
    A --> C[Session index cache]
    A --> D[Foyer data cache]

    B --> B1[Manifest and transaction metadata]
    B --> B2[Decoded deletion vectors]
    B --> B3[File metadata]

    C --> C1[Opened indices]
    C --> C2[Posting lists and positions]
    C --> C3[Index pages and structures]

    D --> D1[Raw range bytes]
    D1 --> D2[data/*.lance]
Loading

This keeps the responsibilities separate:

  • Session metadata cache stores parsed dataset metadata.
  • Session index cache stores parsed and opened index structures.
  • Foyer stores raw range-read bytes from immutable Lance data files.

Feedback is welcome on the proposed scope, configuration API, and whether Foyer is an appropriate dependency for lance-c.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions