-
Notifications
You must be signed in to change notification settings - Fork 317
Binary cache: async push_success #908
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
Changes from 26 commits
95f0438
9d999d8
163d9cd
2a54205
0912655
5d7288c
10189ac
2567607
ecdd000
8e7ae61
850d7c9
548be38
6dbbf06
74b86fd
5171d3e
d69ed8f
2df42d5
5f1786e
93303c3
8a26c8b
aa7e52f
d46a4d6
5e51718
a9ac558
4faf674
b9be8c6
78ca081
579bfa9
103968e
dd32416
b666f94
15bb503
d995bfd
24cd026
92fc76b
3527227
48305b3
27fa076
bcd459a
f958d36
7a24007
50114f9
ca5f2b1
eccd9ee
e7837e0
969e7fc
2d5586f
809d0b6
455e29b
03fdfea
f4bad8c
26bbbd5
814e434
290e586
3cc3378
978ceae
47b56ce
061e6e8
050c51f
8182732
139c7da
4f410f1
73b693a
54fe17f
27780f9
8e15cf4
21de05a
8f372b2
8ecfdaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ namespace vcpkg | |
|
||
struct FileSink; | ||
struct CombiningSink; | ||
struct BGMessageSink; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,17 @@ | |
#include <vcpkg/base/downloads.h> | ||
#include <vcpkg/base/expected.h> | ||
#include <vcpkg/base/files.h> | ||
#include <vcpkg/base/message_sinks.h> | ||
|
||
#include <vcpkg/packagespec.h> | ||
#include <vcpkg/sourceparagraph.h> | ||
|
||
#include <condition_variable> | ||
#include <iterator> | ||
#include <queue> | ||
#include <set> | ||
#include <string> | ||
#include <thread> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
|
@@ -42,6 +47,25 @@ namespace vcpkg | |
const IBinaryProvider* m_available_provider = nullptr; // meaningful iff m_status == available | ||
}; | ||
|
||
struct BinaryPackageInformation | ||
ras0219-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
explicit BinaryPackageInformation(const InstallPlanAction& action, std::string&& nuspec = ""); | ||
autoantwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::string package_abi; | ||
PackageSpec spec; | ||
autoantwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::string raw_version; | ||
std::string nuspec; // only filled if BinaryCache has a provider that returns true for needs_nuspec_data() | ||
autoantwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
struct BinaryProviderPushRequest | ||
{ | ||
BinaryProviderPushRequest(BinaryPackageInformation&& info, Path package_dir) | ||
: info(std::move(info)), package_dir(std::move(package_dir)) | ||
{ | ||
} | ||
BinaryPackageInformation info; | ||
Path package_dir; | ||
autoantwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
struct IBinaryProvider | ||
{ | ||
virtual ~IBinaryProvider() = default; | ||
|
@@ -52,7 +76,8 @@ namespace vcpkg | |
|
||
/// Called upon a successful build of `action` to store those contents in the binary cache. | ||
/// Prerequisite: action has a package_abi() | ||
virtual void push_success(const InstallPlanAction& action) const = 0; | ||
/// returns the number of successful uploads | ||
virtual int push_success(const BinaryProviderPushRequest& request, MessageSink& msg_sink) = 0; | ||
|
||
/// Gives the IBinaryProvider an opportunity to batch any downloading or server communication for | ||
/// executing `actions`. | ||
|
@@ -68,6 +93,8 @@ namespace vcpkg | |
/// to the action at the same index in `actions`. The provider must mark the cache status as appropriate. | ||
/// Prerequisite: `actions` have package ABIs. | ||
virtual void precheck(View<InstallPlanAction> actions, View<CacheStatus*> cache_status) const = 0; | ||
|
||
virtual bool needs_nuspec_data() const { return false; } | ||
}; | ||
|
||
struct UrlTemplate | ||
|
@@ -77,7 +104,7 @@ namespace vcpkg | |
std::vector<std::string> headers_for_get; | ||
|
||
LocalizedString valid() const; | ||
std::string instantiate_variables(const InstallPlanAction& action) const; | ||
std::string instantiate_variables(const BinaryPackageInformation& info) const; | ||
}; | ||
|
||
struct BinaryConfigParserState | ||
|
@@ -124,17 +151,21 @@ namespace vcpkg | |
|
||
struct BinaryCache | ||
{ | ||
BinaryCache() = default; | ||
BinaryCache(Filesystem& filesystem); | ||
explicit BinaryCache(const VcpkgCmdArguments& args, const VcpkgPaths& paths); | ||
|
||
~BinaryCache(); | ||
|
||
void install_providers(std::vector<std::unique_ptr<IBinaryProvider>>&& providers); | ||
void install_providers_for(const VcpkgCmdArguments& args, const VcpkgPaths& paths); | ||
|
||
/// Attempts to restore the package referenced by `action` into the packages directory. | ||
RestoreResult try_restore(const InstallPlanAction& action); | ||
|
||
/// Called upon a successful build of `action` to store those contents in the binary cache. | ||
void push_success(const InstallPlanAction& action); | ||
void push_success(const InstallPlanAction& action, Path package_dir); | ||
|
||
void print_push_success_messages(); | ||
|
||
/// Gives the IBinaryProvider an opportunity to batch any downloading or server communication for | ||
/// executing `actions`. | ||
|
@@ -145,9 +176,27 @@ namespace vcpkg | |
/// Returns a vector where each index corresponds to the matching index in `actions`. | ||
std::vector<CacheAvailability> precheck(View<InstallPlanAction> actions); | ||
|
||
void wait_for_async_complete(); | ||
|
||
private: | ||
struct ActionToPush | ||
{ | ||
BinaryProviderPushRequest request; | ||
bool clean_after_push = false; | ||
autoantwort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
void push_thread_main(); | ||
|
||
BGMessageSink bg_msg_sink; | ||
std::unordered_map<std::string, CacheStatus> m_status; | ||
std::vector<std::unique_ptr<IBinaryProvider>> m_providers; | ||
bool needs_nuspec_data = false; | ||
std::condition_variable actions_to_push_notifier; | ||
std::mutex actions_to_push_mutex; | ||
std::vector<ActionToPush> actions_to_push; | ||
std::thread push_thread; | ||
std::atomic_bool end_push_thread; | ||
std::atomic_int remaining_packages_to_push = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A rule of thumb is BG: actions_to_push_notifier.wait(pred) result: Deadlock There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if atomic is kept I prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! The documentation at cppreference also mentions that in the first block 🤦 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not exactly the sum. It is the size of one vector + the remaining elements of a second vector that is currently processed. (And the second vector is currently not available where |
||
Filesystem& filesystem; | ||
}; | ||
|
||
ExpectedL<DownloadManagerConfig> parse_download_configuration(const Optional<std::string>& arg); | ||
|
Uh oh!
There was an error while loading. Please reload this page.