[go: up one dir, main page]

Skip to content
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

feat(provider): LRUCache Layer #954

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open

feat(provider): LRUCache Layer #954

wants to merge 37 commits into from

Conversation

yash-atreya
Copy link
Member
@yash-atreya yash-atreya commented Jun 21, 2024

Motivation

Ref: #770

Solution

WIP

  • Adds a provider caching layer that dumps cache to fs.
  • Responses are saved as key-value pairs where key is the hash of the serialized request params.

TODO

  • Handlers for access save_cache and load_cache via provider.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

crates/provider/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/provider/src/layers/cache.rs Show resolved Hide resolved
crates/provider/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/provider/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/provider/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/provider/src/layers/cache.rs Outdated Show resolved Hide resolved
@yash-atreya yash-atreya mentioned this pull request Jun 27, 2024
10 tasks
@yash-atreya yash-atreya changed the title feat(providers): LRUCache Layer feat(transport): LRUCache Layer Aug 5, 2024
Copy link
Member
@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

some suggestions

crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
@yash-atreya yash-atreya marked this pull request as ready for review August 6, 2024 11:49
Copy link
Member
@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

some questions

crates/transport/Cargo.toml Outdated Show resolved Hide resolved
crates/provider/src/provider/trait.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
crates/transport/src/layers/cache.rs Outdated Show resolved Hide resolved
@yash-atreya yash-atreya added the blocked This cannot move forward until something else changes label Sep 9, 2024
@yash-atreya
Copy link
Member Author

Decided to make this a provider-layer, this lets us achieve two very important features that wouldn't work as a transport layer:

  1. Let users access save_cache and load_cache on demand via the provider interface. In the case of a ransport layer this would only work when the layer is dropped and initialized respectively.
  2. Requests that use BlockId tags like latest, pending etc. should not use cache. This becomes trivial to implement as a provider layer.

To accomplish this we need to merge #788

@yash-atreya yash-atreya removed the blocked This cannot move forward until something else changes label Sep 19, 2024
let cache = CacheLayer::new(100);
let anvil = Anvil::new().block_time_f64(0.3).spawn();
let provider = ProviderBuilder::default()
// .with_recommended_fillers() - TODO: Issue here. Layer doesn't work with fillers. Fix.
Copy link
Member Author

Choose a reason for hiding this comment

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

Enabling fillers would wrap the CacheProvider or any other layer provider in a FillProvider. Making methods on CacheProvider inaccessible. i.e provider.load_cache(path) won't work but provider.inner.load_cache(path) works.

This is not ideal.

@yash-atreya yash-atreya changed the title feat(transport): LRUCache Layer feat(provider): LRUCache Layer Sep 27, 2024
@yash-atreya yash-atreya self-assigned this Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants