Skip to content

Cap batch partitions by target batch size when files < numTasks#2149

Draft
airspeedswift wants to merge 1 commit into
swiftlang:mainfrom
airspeedswift:batch-partition-target-size
Draft

Cap batch partitions by target batch size when files < numTasks#2149
airspeedswift wants to merge 1 commit into
swiftlang:mainfrom
airspeedswift:batch-partition-target-size

Conversation

@airspeedswift

Copy link
Copy Markdown
Member

The previous formula max(numTasks, ceil(numFiles/sizeLimit)) forced at least numTasks partitions, which when numFiles <= numTasks results in approximately one file per partition and defeats the per-process amortization (TypeConverter, IRGen TypeConverter, deserialized decl/type caches, requirement machine) that batch mode is meant to provide.

Cap partition count by ceil(numFiles / preferredBatchSize) when that yields a smaller value than numTasks, so small modules get fewer, larger batches that can share per-process state across files.

The previous formula `max(numTasks, ceil(numFiles/sizeLimit))` forced
at least `numTasks` partitions, which when `numFiles <= numTasks`
results in approximately one file per partition and defeats the
per-process amortization (TypeConverter, IRGen TypeConverter,
deserialized decl/type caches, requirement machine) that batch mode is
meant to provide.

Cap partition count by `ceil(numFiles / preferredBatchSize)` when that
yields a smaller value than `numTasks`, so small modules get fewer,
larger batches that can share per-process state across files.
@airspeedswift airspeedswift force-pushed the batch-partition-target-size branch from e187a46 to 586fd9f Compare May 29, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant