Skip to content

dedup parallel download of the same file - #31039

Open
scaiper wants to merge 2 commits into
bazelbuild:masterfrom
scaiper:dedup-parallel-downloads
Open

dedup parallel download of the same file#31039
scaiper wants to merge 2 commits into
bazelbuild:masterfrom
scaiper:dedup-parallel-downloads

Conversation

@scaiper

@scaiper scaiper commented Sep 8, 2026

Copy link
Copy Markdown

Description

Concurrent fetches of the same file are deduplicated: one downloads, while other fetches wait and copy the resulting file.

Motivation

fixes #12420

Build API Changes

No

Checklist

  • [x ] I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable). (not applicable)

Release Notes

RELNOTES: Concurrent fetches of identical files are now deduplicated so that the file is downloaded only once.


// Downloads of identical content requested concurrently (e.g. two repos with the same URL) are
// coalesced so that only the first one transfers bytes; the rest copy the resulting file.
private final ConcurrentHashMap<String, CompletableFuture<Path>> inFlightDownloads =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use TaskDeduplicator instead as it correctly handles cancelation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the code to use TaskDeduplicator. There are quite a bit of changes, but it's mostly moved lines.

@scaiper
scaiper marked this pull request as ready for review September 8, 2026 13:18
@github-actions github-actions Bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Sep 8, 2026
@fmeum

fmeum commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Sorry for the churn, but I looked into this a bit more and would like to merge #31040 and #31041 first, which fix a related a bug and clean up the overall structure.

@scaiper

scaiper commented Sep 8, 2026

Copy link
Copy Markdown
Author

Sure, sounds good. Let me know when it’s ready—or feel free to make the changes directly in my PR if that’s easier.

@meteorcloudy
meteorcloudy self-requested a review September 9, 2026 15:09
@meteorcloudy

Copy link
Copy Markdown
Member

Both #31040 and #31041 are now merged, can you please update this PR?

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

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate URLs get fetched twice

3 participants