Skip to content

feat(hermes): configurable cache size #2547

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

Merged
merged 4 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
.git

!apps/hermes/server/src/state/cache.rs
!apps/hermes/server/src/config/cache.rs
2 changes: 1 addition & 1 deletion apps/argus/Cargo.lock
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't know why this diff is being shown, this file isn't different vs main..

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hermes"
version = "0.8.4"
version = "0.8.5"
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
edition = "2021"

Expand Down
5 changes: 5 additions & 0 deletions apps/hermes/server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use clap::{crate_authors, crate_description, crate_name, crate_version, Args, Pa

mod aggregate;
mod benchmarks;
mod cache;
mod metrics;
mod pythnet;
mod rpc;
Expand All @@ -24,6 +25,10 @@ pub enum Options {

#[derive(Args, Clone, Debug)]
pub struct RunOptions {
/// Cache Options
#[command(flatten)]
pub cache: cache::Options,

/// Aggregate Options
#[command(flatten)]
pub aggregate: aggregate::Options,
Expand Down
18 changes: 18 additions & 0 deletions apps/hermes/server/src/config/cache.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use clap::Args;

#[derive(Args, Clone, Debug)]
#[command(next_help_heading = "Cache Options")]
#[group(id = "Cache")]
pub struct Options {
/// The maximum number of slots to cache.
///
/// This controls how many historical price updates are kept in memory.
/// Higher values increase memory usage but allow access to more historical data
/// without falling back to Benchmarks.
///
/// Default is 1600 slots, which gives 640 seconds of cached updates.
#[arg(long = "cache-size-slots")]
#[arg(env = "CACHE_SIZE_SLOTS")]
#[arg(default_value = "1600")]
pub size_slots: u64,
}
2 changes: 1 addition & 1 deletion apps/hermes/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn init() -> Result<()> {
// Initialize a cache store with a 1000 element circular buffer.
let state = state::new(
update_tx.clone(),
1000,
opts.cache.size_slots,
opts.benchmarks.endpoint.clone(),
opts.aggregate.readiness_staleness_threshold.into(),
opts.aggregate.readiness_max_allowed_slot_lag,
Expand Down
Loading