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: reduce budget on recurring requests #498

Open
Theodus opened this issue Jan 9, 2024 · 0 comments
Open

feat: reduce budget on recurring requests #498

Theodus opened this issue Jan 9, 2024 · 0 comments

Comments

@Theodus
Copy link
Member

Theodus commented Jan 9, 2024

Since indexers do caching on their end, the gateway should detect recurring request hashes (potentially using requestCID in attestation) and reduce the budget on those queries once they meet some threshold.

Most queries will not meet this threshold. However, for the ones that do this will mitigate desires to cache query responses in the gateway. Rough pseudocode proposal:

pub struct Budgeter {
  // This must match the hashes of deterministic requests, including variables.
  // This can be cleared periodically, since nearly all entries will be short-lived.
  recurring_requests: RwLock<Set<Hash>>,
  ...
}
impl Budgeter {
  ...
  pub async fn budget(&self, hash: Hash) -> GRT {
    let mut budget = ...;
    if self.recurring_requests.read().await.contains(&hash) {
     budget *= 0.1;
    }
    budget
  }
  pub fn add_request(&mut self, hash: Hash) {
    self.recurring_requests.try_lock.insert(hash);
  }
}

open questions

  • How might this interact with auto-agora?
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

No branches or pull requests

1 participant