Skip to content

Commit b2c9bbe

Browse files
committed
graph, store: Change how many stale contracts get deleted in one batch
Introduce an env variable to control that, and lower the default to 100
1 parent 90b8248 commit b2c9bbe

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

graph/src/env/store.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ pub struct EnvVarsStore {
171171
/// Disables storing or reading `eth_call` results from the store call cache.
172172
/// Set by `GRAPH_STORE_DISABLE_CALL_CACHE`. Defaults to false.
173173
pub disable_call_cache: bool,
174+
/// The number of contracts to delete from the call cache in one batch
175+
/// when clearing stale entries, set by
176+
/// `GRAPH_STORE_STALE_CALL_CACHE_CONTRACTS_BATCH_SIZE`. The default
177+
/// value is 100 contracts.
178+
pub stale_call_cache_contracts_batch_size: usize,
174179
/// Set by `GRAPH_STORE_DISABLE_CHAIN_HEAD_PTR_CACHE`. Default is false.
175180
/// Set to true to disable chain_head_ptr caching (safety escape hatch).
176181
pub disable_chain_head_ptr_cache: bool,
@@ -248,6 +253,7 @@ impl TryFrom<InnerStore> for EnvVarsStore {
248253
account_like_min_versions_count: x.account_like_min_versions_count,
249254
account_like_max_unique_ratio: x.account_like_max_unique_ratio.map(|r| r.0),
250255
disable_call_cache: x.disable_call_cache,
256+
stale_call_cache_contracts_batch_size: x.stale_call_cache_contracts_batch_size,
251257
disable_chain_head_ptr_cache: x.disable_chain_head_ptr_cache,
252258
connection_validation_idle_secs: Duration::from_secs(x.connection_validation_idle_secs),
253259
connection_unavailable_retry: Duration::from_secs(
@@ -364,6 +370,11 @@ pub struct InnerStore {
364370
account_like_max_unique_ratio: Option<ZeroToOneF64>,
365371
#[envconfig(from = "GRAPH_STORE_DISABLE_CALL_CACHE", default = "false")]
366372
disable_call_cache: bool,
373+
#[envconfig(
374+
from = "GRAPH_STORE_STALE_CALL_CACHE_CONTRACTS_BATCH_SIZE",
375+
default = "100"
376+
)]
377+
stale_call_cache_contracts_batch_size: usize,
367378
#[envconfig(from = "GRAPH_STORE_DISABLE_CHAIN_HEAD_PTR_CACHE", default = "false")]
368379
disable_chain_head_ptr_cache: bool,
369380
#[envconfig(from = "GRAPH_STORE_CONNECTION_VALIDATION_IDLE_SECS", default = "30")]

store/postgres/src/chain_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3287,7 +3287,7 @@ impl ChainStoreTrait for ChainStore {
32873287
// entries into memory at once. Each contract can have many
32883288
// calls, so we delete calls in adaptive batches that
32893289
// self-tune based on query duration.
3290-
let contracts_batch_size: usize = 2000;
3290+
let contracts_batch_size: usize = ENV_VARS.store.stale_call_cache_contracts_batch_size;
32913291
let mut batch_size = AdaptiveBatchSize::with_size(100);
32923292

32933293
// Limits the number of contracts to process if ttl_max_contracts is set.

0 commit comments

Comments
 (0)