Skip to content

Commit a71ca2d

Browse files
committed
feat: configurable cache size, bump default to 2000 slots
1 parent b8f388e commit a71ca2d

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

apps/argus/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/hermes/server/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use clap::{crate_authors, crate_description, crate_name, crate_version, Args, Pa
22

33
mod aggregate;
44
mod benchmarks;
5+
mod cache;
56
mod metrics;
67
mod pythnet;
78
mod rpc;
@@ -24,6 +25,10 @@ pub enum Options {
2425

2526
#[derive(Args, Clone, Debug)]
2627
pub struct RunOptions {
28+
/// Cache Options
29+
#[command(flatten)]
30+
pub cache: cache::Options,
31+
2732
/// Aggregate Options
2833
#[command(flatten)]
2934
pub aggregate: aggregate::Options,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use clap::Args;
2+
3+
#[derive(Args, Clone, Debug)]
4+
#[command(next_help_heading = "Cache Options")]
5+
#[group(id = "Cache")]
6+
pub struct Options {
7+
/// The maximum number of slots to cache.
8+
///
9+
/// This controls how many historical price updates are kept in memory.
10+
/// Higher values increase memory usage but allow access to more historical data
11+
/// without falling back to Benchmarks.
12+
///
13+
/// Default is 2000 slots, which gives ~13 minutes of cached updates.
14+
#[arg(long = "cache-size-slots")]
15+
#[arg(env = "CACHE_SIZE_SLOTS")]
16+
#[arg(default_value = "2000")]
17+
pub size_slots: u64,
18+
}

apps/hermes/server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async fn init() -> Result<()> {
4444
// Initialize a cache store with a 1000 element circular buffer.
4545
let state = state::new(
4646
update_tx.clone(),
47-
1000,
47+
opts.cache.size_slots,
4848
opts.benchmarks.endpoint.clone(),
4949
opts.aggregate.readiness_staleness_threshold.into(),
5050
opts.aggregate.readiness_max_allowed_slot_lag,

0 commit comments

Comments
 (0)