-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary cache: async push_success #908
Draft
autoantwort
wants to merge
60
commits into
microsoft:main
Choose a base branch
from
autoantwort:feature/async-binary-cache-push-success
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
95f0438
Binary cache: async push_success
autoantwort 9d999d8
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 163d9cd
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 2a54205
Apply suggestions from code review
autoantwort 0912655
Adapt code review
autoantwort 5d7288c
Update src/vcpkg/binarycaching.cpp
autoantwort 10189ac
Adapt code review
autoantwort 2567607
Remove unnecessary actions_to_push_notifier.notify_all()
autoantwort ecdd000
Prevent deadlock and don't be on the crtl+c path
autoantwort 8e7ae61
Add and use BGMessageSink to print IBinaryProvider::push_success mess…
autoantwort 850d7c9
Restore old upload message
autoantwort 548be38
Don't join yourself
autoantwort 6dbbf06
Print messages about remaining packages to upload
autoantwort 74b86fd
Localization
autoantwort 5171d3e
Improve messages
autoantwort d69ed8f
No singleton and explicit calls to wait_for_async_complete()
autoantwort 2df42d5
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 5f1786e
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 93303c3
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 8a26c8b
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort aa7e52f
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort d46a4d6
Apply code review
autoantwort 5e51718
Trigger Build
autoantwort a9ac558
No rename dance
autoantwort 4faf674
Print upload to provider only once and not once per provider
autoantwort b9be8c6
Fix tests
autoantwort 78ca081
Don't create unnecessary strings
autoantwort 579bfa9
Rename to m_published_lock
autoantwort 103968e
BinaryPackageInformation use Optional and make BinaryProviderPushRequ…
autoantwort dd32416
Merge branch 'main' into feature/async-binary-cache-push-success and …
autoantwort b666f94
Add missing files
autoantwort 15bb503
Add missing includes
autoantwort d995bfd
Make BianryCache a unique_ptr
autoantwort 24cd026
Reduce changes
autoantwort 92fc76b
Fix output
autoantwort 3527227
Fix bug
autoantwort 48305b3
Format
autoantwort 27fa076
Use lock_guard
autoantwort bcd459a
Revert "Use lock_guard"
autoantwort f958d36
Use enum
autoantwort 7a24007
BGMessageSink::print_published apply code review
autoantwort 50114f9
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort ca5f2b1
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort eccd9ee
Fix typo
autoantwort e7837e0
Fix typo in file name
autoantwort 969e7fc
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 2d5586f
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 809d0b6
Renamings
autoantwort 455e29b
format
autoantwort 03fdfea
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort f4bad8c
BinaryCache and std::unique_ptr
autoantwort 26bbbd5
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 814e434
BinaryCache: save data in std::unique_ptr so that the object can be m…
autoantwort 290e586
fix
autoantwort 3cc3378
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 978ceae
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 47b56ce
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 061e6e8
Merge branch 'main' into feature/async-binary-cache-push-success
autoantwort 050c51f
Merge remote-tracking branch 'origin/main' into feature/async-binary-…
BillyONeal 8182732
Merge remote-tracking branch 'origin/main' into feature/async-binary-…
BillyONeal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#pragma once | ||
|
||
#include <condition_variable> | ||
#include <mutex> | ||
#include <vector> | ||
|
||
template<class T> | ||
class BatchQueue | ||
{ | ||
public: | ||
template<class... Args> | ||
void push(Args&&... args) | ||
{ | ||
forward.emplace_back(std::forward<Args>(args)...); | ||
} | ||
|
||
bool empty() const { return forward.empty(); } | ||
|
||
void pop(std::vector<T>& out) | ||
{ | ||
out.clear(); | ||
swap(out, forward); | ||
} | ||
|
||
private: | ||
std::vector<T> forward; | ||
}; | ||
|
||
template<class WorkItem> | ||
struct BGThreadBatchQueue | ||
{ | ||
template<class... Args> | ||
void push(Args&&... args) | ||
{ | ||
std::lock_guard<std::mutex> lock(m_mtx); | ||
m_tasks.push(std::forward<Args>(args)...); | ||
m_cv.notify_all(); | ||
} | ||
|
||
void wait_for_items(std::vector<WorkItem>& out) | ||
{ | ||
std::unique_lock<std::mutex> lock(m_mtx); | ||
m_cv.wait(lock, [this]() { return !m_tasks.empty() || !m_running; }); | ||
m_tasks.pop(out); | ||
} | ||
|
||
void stop() | ||
{ | ||
std::lock_guard<std::mutex> lock(m_mtx); | ||
m_running = false; | ||
m_cv.notify_all(); | ||
} | ||
|
||
bool stopped() | ||
{ | ||
std::lock_guard<std::mutex> lock(m_mtx); | ||
return !m_running; | ||
} | ||
|
||
private: | ||
std::mutex m_mtx; | ||
std::condition_variable m_cv; | ||
BatchQueue<WorkItem> m_tasks; | ||
bool m_running = true; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ namespace vcpkg | |
|
||
struct FileSink; | ||
struct TeeSink; | ||
struct BGMessageSink; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1720,6 +1720,8 @@ | |
"_VersionSpecMismatch.comment": "An example of {path} is /foo/bar. An example of {expected_version} is 1.3.8. An example of {actual_version} is 1.3.8.", | ||
"VersionVerifiedOK": "{version_spec} is correctly in the version database ({git_tree_sha})", | ||
"_VersionVerifiedOK.comment": "An example of {version_spec} is zlib:[email protected]. An example of {git_tree_sha} is 7cfad47ae9f68b183983090afd6337cd60fd4949.", | ||
"WaitUntilPackagesUploaded": "Wait until the remaining packages ({count}) are uploaded", | ||
"_WaitUntilPackagesUploaded.comment": "An example of {count} is 42.", | ||
"WaitingForChildrenToExit": "Waiting for child processes to exit...", | ||
"WaitingToTakeFilesystemLock": "waiting to take filesystem lock on {path}...", | ||
"_WaitingToTakeFilesystemLock.comment": "An example of {path} is /foo/bar.", | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this thing being called queue given that this is how it works. Given that we expect this to be a multi producer single consumer queue, can we instead put the vector inside and note that only one thread may call pop but any number of threads may call push? That would also resolve the criticism over separate tracking atomics below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BatchQueue
alone is not thread safe.I don't get what you have in mind here 😅
Do you have an idea for a better name? :)