-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Per-request caches and dependency maps #35206
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
Conversation
bd3ea17
to
7b86366
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
7b86366
to
2ffe1d3
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
swiftlang/llvm-project#2279 |
Glad you were able to put the patch to use! Another approach I was experimenting with (originally suggested by @CodaFi) was to instead allow small requests and outputs to be stored inline in
However I was getting some regressions for I was also planning on (but never started) experimenting with stamping out specialized caches for e.g AST nodes that would store all the request outputs together (essentially mimicking external caching storage but encapsulated within the evaluator), but that can be done on top of any caching implementation. |
This becomes tricky with the new per-request cache representation. We can add it back later if we need it, but I feel like this code path isn't particularly useful right now anyway.
This is based on an earlier patch by @hamishknight. The idea is that instead of caching results in a single DenseMap that maps AnyRequest to AnyValue, we instead define a separate DenseMap for each request kind that directly uses the request as the key, and the request value as the value. This avoids type erasure and memory allocation overhead arising from the use of AnyRequest and AnyValue. There are no remaining usages of AnyValue, and the only usage of AnyRequest is now in the reference dependency tracking, which can be refactored to use a similar strategy of storing per-request maps as well.
... instead of passing around an ActiveRequest.
Just as with the result cache, instead of a single DenseMap with type-erased AnyRequest keys, we can use per-request maps for a nice performance improvement.
00ed02d
to
0bfa868
Compare
@hamishknight I'll leave AnyValue and AnyRequest in place for now. |
@swift-ci Please smoke test |
swiftlang/llvm-project#2279 |
swiftlang/llvm-project#2279 |
Build failed |
@swift-ci Please test Linux |
Build failed |
swiftlang/llvm-project#2279 |
swiftlang/llvm-project#2279 |
Build failed |
swiftlang/llvm-project#2279 |
Build failed |
@swift-ci Please test Linux |
Based on @hamishknight's PR #31143.