← Back to Pull requests

[Spark] List _change_data separately to speed up VACUUM listing #7448

Open
unknown opened this pull request with 462 lines diff across 5 files
View on GitHub
unknown unknown commented on Aug 12, 2026 16:52 UTC
Author

Description

VACUUM now lists the table's _change_data directory as its own listing branch instead of recursing into it inline. Gated by an internal config (vacuum.listing.changeDataDirSeparately.enabled, default true).

Resolves #7447. Related to #2201 (closed) — same listing-parallelism bottleneck, targeted at the common CDF case rather than a general initialListingDepth knob.

Why

VACUUM discovers files by:

1. shallow-listing the table root,
2. distributing that first level across the cluster, then
3. recursing each first-level directory in a single task.

_change_data is one of those first-level directories, and it mirrors the table's partitioning (or is a single large flat directory), so it can hold a large fraction of the table's files. Recursing it inline leaves one task listing that entire subtree while the rest of the cluster is idle — typically the tail of VACUUM on tables with Change Data Feed enabled. Simply deepening the initial listing does not help the common case where _change_data is a flat directory: there are no sub-directories to spread, so it is still a single listStatus.

What changed

  • VacuumCommand.getFilesFromFilesystem excludes the table root's _change_data from the main listing and lists it through a separate recursiveListDirs call. Its sub-directories then get their own repartition + parallel recursion, and because the two branches are unioned Spark schedules them concurrently.

  • DeltaFileOperations.recursiveListDirs gets an optional firstLevelHiddenDirNameFilter (default: hides nothing). It applies only to the first, non-recursive listing of the given roots, while hiddenDirNameFilter applies at every depth. VACUUM uses it to exclude the root's _change_data, so a _change_data directory deeper in the tree (for example part=1/_change_data/) is still part of the main listing.

  • The _change_data directory entry itself is emitted explicitly (the listing helper emits the contents of its roots, not the roots), so empty-directory cleanup behaves exactly as before.

  • One getFileStatus call decides the path. If the table has no _change_data directory, _change_data is a file, or the config is off, the original single-call listing path is used unchanged.
  • The set of files considered by VACUUM is identical; only the listing parallelism differs.

    Benchmark

    VACUUM ... RETAIN 0 HOURS DRY RUN (listing only, no deletes) on a 10,000-partition CDF-enabled table whose _change_data subtree mirrors the partitioning (10,000 sub-directories, one file each), over cloud object storage, 3 interleaved runs per mode:

    | Mode | runs (s) | best (s) |
    | --- | --- | --- |
    | inline (current) | 117.6, 84.8, 110.6 | 84.8 |
    | separate branch | 31.8, 28.3, 29.3 | 28.3 |

    Best-of-3 ≈ 3.0× faster listing; both modes return the identical 10,000 candidate files.

    How was this patch tested?

  • VACUUM removes the same untracked _change_data files whether listed separately or inline — end-to-end SQL VACUUM run with the config both on and off. It checks that the same untracked files are removed and the tracked file is kept. The untracked files include one nested deep under _change_data and one in a _change_data directory below a partition directory (part=1/_change_data/orphan.txt).
  • DeltaVacuumSuite passes locally.

    Does this PR introduce _any_ user-facing changes?

    No. The set of files VACUUM considers is unchanged; this only changes listing parallelism. The behavior is gated by an internal config that defaults on and falls back to the original path when there is no _change_data directory.

    🤖 Generated with Claude Code

    Diff: 462 lines (+346 / -116) across 5 files Reviewer: sezruby Review duration: 158794m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.53) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.53 · 462 lines diff across 5 files
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #7448"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.6% (MEDIUM) · Higher = larger blast radius
    52.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.1% · Safe to merge
    29.1%
    Repository