-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SwiftScan] Add SwiftScan APIs to replay the cache output #68660
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
[SwiftScan] Add SwiftScan APIs to replay the cache output #68660
Conversation
I was trying to abstract out the compilation to avoid re-parsing command line, compute input/output and create instance in replay logics, but it turns out a lots of information needs to be passed, including:
So stick with replaying from command-line for now. |
@swift-ci please smoke test |
537f604
to
68edb2c
Compare
@swift-ci please smoke test |
The libclang API has this kind of interaction with the build system:
Separating (1) from (2) provides flexibility on the client side for treating them as separate actions that can be recorded in the build log with their own timing info and executed potentially with different priority/scheduling. I would prefer to preserve that for swift as well instead of And once an opaque object for outputs is introduced you can pass it to |
Maybe. But isn't that more round trip to remote that just adds latency? Maybe query can return faster without download, but what do you do if query succeed but materialize failed? Isn't that the same as a miss? |
Key/value queries are separated from CAS actions, both in the LLVMCAS APIs and the network protocols, there's no saving of latency in putting them behind one C API function instead of two.
Yes, the client should treat it as a miss (or not, it is up to the client, maybe in a more strict mode it prefers to fail if the CAS download was not found, that's the benefit of the additional flexibility and control) and it will be more transparent to the client what exact action failed. |
68edb2c
to
7dd33b0
Compare
Split |
@swift-ci please smoke test |
7dd33b0
to
0d56a00
Compare
@swift-ci please test |
I'm a bit unclear on the intended design for the replay function. Currently it works by triggering a performFrontend that internally does the caching. IIUC that will replay all the cached compilations associated with that frontend job in the case of batch mode. But if we have multiple keys for that and you have added one key parameter to the function for future use, won't you then need to make multiple calls to the same function? I wonder if we should have a list of keys instead? I assume that even after you stop using performFrontend, you need to setup some state from the compiler arguments to do the replay. That seems like something we want to avoid repeating multiple times for the same invocation if possible. |
See my comment in the beginning. #68660 (comment) The ideal situation is to replay from each key but the number of API required will grow significantly and might not be very stable. I was thinking if there are better way to communicate (like setup replay state from a JSON or a CAS object). |
After offline discussion, we are going to revise the cache key structure and this patch will be updated with the new design in mind later. |
0d56a00
to
9177399
Compare
Update the patch to using the new cache key schema and new C APIs. Add a tool |
@swift-ci please smoke test |
9177399
to
9565794
Compare
@swift-ci please smoke test |
9565794
to
0d1c792
Compare
@swift-ci please smoke test |
eb0eeb8
to
e640e14
Compare
Also rewrite the patch to split Caching related code from DependencyScanning related code in libSwiftScan implementation so the file gets smaller and easier to read. |
@swift-ci please smoke test |
Change how cached diagnostics are stored inside the CAS. It used to be stored as a standalone entry for a frontend invocation in the cache and now it is switched to be associated with input files, stored together with other outputs like object files, etc. This enables cleaner Cache Replay APIs and future cached diagnostics that can be splitted up by file contribution.
e640e14
to
ced0922
Compare
@swift-ci please smoke test |
ced0922
to
b8f5226
Compare
@swift-ci please smoke test |
b8f5226
to
ef24432
Compare
@swift-ci please smoke test |
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.
Could you add a swiftscan_cached_output_get_casidstring
function, it will be useful for the client for logging purposes.
I also foresee a need for something like swiftscan_cache_compilation_is_uncacheable
, for the case that the compiler decided that the compilation was uncacheable, so the client can distinguish this case. I'd suggest to add the function as a stub (always returning false) so clients can call it, and implement it properly in a future PR once we find a case for marking a key as 'uncacheable'.
ef24432
to
ad78812
Compare
@swift-ci please smoke test |
ad78812
to
e5076cb
Compare
@swift-ci please smoke test |
e5076cb
to
79118aa
Compare
@swift-ci please smoke test |
Add new APIs libSwiftScan that can be used for cache query and cache replay. This enables swift-driver or build system to query the cache and replay the compilation results without invocation swift-frontend for better scheduling.
79118aa
to
034c15c
Compare
@swift-ci please smoke test |
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.
Thank you for addressing all the feedback!
@swift-ci please smoke test windows platform |
Add new C APIs to libSwiftScan for cache querying and cache replays.