[Spark] Add vacuum.listing.initialDepth to improve VACUUM listing parallelism - #13
Closed
sezruby wants to merge 1 commit into
Closed
[Spark] Add vacuum.listing.initialDepth to improve VACUUM listing parallelism#13sezruby wants to merge 1 commit into
sezruby wants to merge 1 commit into
Conversation
…allelism VACUUM lists the table's file system by shallow-listing the table root, re-distributing that first level across the cluster, and then recursing each first-level directory in a single task. When the first level is skewed -- a low-cardinality partition column, or a large `_change_data` directory -- one task ends up listing an entire subtree while the rest of the cluster sits idle, which dominates VACUUM time on large tables. This adds `spark.databricks.delta.vacuum.listing.initialDepth` (default 1, which preserves the existing behavior exactly). Values greater than 1 make `recursiveListDirs` descend that many directory levels breadth-first, re-distributing the frontier after each level, before handing the remaining directories to the parallel subtree recursion. This yields a larger, better-spread set of directories to parallelize over. The set of files considered by VACUUM is unchanged for any depth; only the listing parallelism differs. A new test asserts this depth-invariance over a tree with files at multiple depths and nested empty directories, and an end-to-end VACUUM test confirms untracked files nested deeper than the configured depth are still discovered and removed. Addresses delta-io#2201. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Superseded by #14. Switched approach from a whole-tree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an opt-in
spark.databricks.delta.vacuum.listing.initialDepthconfig(default
1) that controls how many directory levels VACUUM listsbreadth-first before fanning out to the parallel recursive listing.
Addresses delta-io#2201.
Why
VACUUM discovers files by:
When the first level is skewed, step 3 dominates: one task lists an entire
subtree while the rest of the cluster is idle. Common causes are a
low-cardinality partition column (a handful of top-level partition dirs,
each huge) and a large
_change_datadirectory. On big tables this makesthe listing phase the bottleneck of VACUUM.
What changed
recursiveListDirstakes a newinitialListingDepthparameter. Fordepth > 1it descends that many levels breadth-first, re-distributingthe frontier after each level, before handing the remaining directories
to the existing parallel subtree recursion. Files and interior
directories found along the way are emitted as they are discovered.
depth = 1(the default) reduces to exactly the previous code path, sobehavior is unchanged unless the config is set.
VacuumCommandreads the new config and passes it through.The set of files considered by VACUUM is identical for any depth; only
the listing parallelism differs.
Tests
recursiveListDirs returns the same files and directories for any initialListingDepth— builds a tree with files at multiple depths andnested empty directories, and asserts depths 2–5 produce the exact same
set as depth 1 (depth-invariance).
recursiveListDirs rejects a non-positive initialListingDepth.VACUUM with a larger vacuum.listing.initialDepth deletes the same untracked files— end-to-end SQL VACUUM withinitialDepth=3, confirmingan untracked file nested deeper than the configured depth is still
discovered and removed while the tracked file is retained.
All three pass locally (
spark/testOnly ... DeltaVacuumSuite).🤖 Generated with Claude Code