Skip to content

[Design]: spill storage v2 with segment indexes, bounded active FDs, and adaptive fanout #26435

Closed as not planned

Description

@XuPeng-SH

Context

Follow-up from #26408 and #26412. The current spill engine is now ownership-safe, but its fixed fanout and one-file-per-bucket/re-spill layout remain a major resource and performance bottleneck.

A representative 8192-build/9216-probe initial-spill plus re-spill run still performs about 2110 FD reservations, creates about 2078 files, and allocates about 85.7 MB. File creation and appendScatterRecord dominate the remaining cost.

Problem

  • Fixed 32-way fanout is not derived from estimated bytes, cardinality, or skew.
  • Independent bucket files create thousands of microfiles and excessive open/close/reservation work.
  • File identities are tied to live descriptors instead of named, reopenable partition handles.
  • The current frame format lacks an explicit version/checksum contract for durable corruption detection and evolution.
  • Service-local FD accounting cannot bound the process-wide active descriptor window by itself.

Proposed direction

  • Store many partitions in segment files with an offset/index structure.
  • Represent partitions as named, reopenable handles independent of a permanently open FD.
  • Bound the active FD window through a CN/process-level broker with explicit headroom.
  • Choose fanout adaptively from estimated bytes/cardinality and observed skew.
  • Define versioned, checksummed frames and compatibility rules for readers/writers.
  • Reduce per-row/per-record scatter allocations and batch metadata churn.

Acceptance criteria

  • The representative workload creates a bounded number of segments/active FDs rather than O(bucket-rounds) files.
  • Partition row/byte conservation holds across initial spill, reduced fanout, and re-spill.
  • Corrupt headers, payloads, indexes, and checksums return stable errors with complete resource cleanup.
  • Reopen/evict/retry/cancellation tests prove exactly-once disk, FD, memory-budget, and mpool release.
  • Adaptive fanout is deterministic under fixed estimates and remains bounded for inaccurate estimates.
  • End-to-end resource/performance benchmarks report files, peak active FDs, spill bytes, allocations, and latency, with regression guardrails.
  • Mixed-version format behavior is explicitly tested and documented.

Related: #26408, #26412.

Activity

  1. self-assigned this
    on Jul 30, 2026
  2. XuPeng-SH commented on Aug 1, 2026

    @XuPeng-SH
    ContributorAuthor

    Roadmap decision: #26563. This is evidence-gated performance/availability work, not a current correctness prerequisite. Start only if normal workloads show FD admission failures, active FDs approaching the cap, or create/close/scatter consuming a material share of spill time. If triggered, begin with the smallest segment + offset-index change; durable format, checksums, mixed-version temp-file compatibility, and adaptive fanout remain non-goals for the first PR.

  3. XuPeng-SH commented on Aug 12, 2026

    @XuPeng-SH
    ContributorAuthor

    Superseded by #27026.

    The current-main audit confirms that fixed fanout and bucket files remain, but it does not show a normal-workload FD admission failure, an active-FD window near the cap, or file/scatter overhead dominating spill wall time. Later allocation-accounting, classifier, and write-coalescing changes also make this issue's original benchmark stale as an implementation trigger.

    The successor records a quantitative go/no-go gate. If that gate is met, the implementation follow-up will contain only the smallest segment + offset-index change; adaptive fanout, checksums, durable format, and mixed-version compatibility remain separate non-goals.

    Closing this broad design as superseded, not completed.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions