Skip to content

Commit

Permalink
[Indexer-grpc] Allow in mem cache to return more txns (500 -> 5000). (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
grao1991 authored Jul 10, 2024
1 parent e5f4b62 commit 2d60c78
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const IN_MEMORY_CACHE_GC_INTERVAL_MS: u64 = 100;
// Warm-up cache entries. Pre-fetch the cache entries to warm up the cache.
pub const WARM_UP_CACHE_ENTRIES: u64 = 100;
pub const MAX_REDIS_FETCH_BATCH_SIZE: usize = 500;
pub const MAX_FETCH_BATCH_SIZE: usize = 5000;

/// Configuration for when we want to explicitly declare how large the cache should be.
#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -157,7 +158,7 @@ impl InMemoryCache {
// This is to avoid fetching too many transactions at once.
let ending_version = std::cmp::min(
latest_version,
starting_version + MAX_REDIS_FETCH_BATCH_SIZE as u64,
starting_version + MAX_FETCH_BATCH_SIZE as u64,
);
break (
(starting_version..ending_version).collect::<Vec<u64>>(),
Expand Down Expand Up @@ -255,7 +256,7 @@ fn spawn_update_task<C>(
}
let end_version = std::cmp::min(
current_latest_version,
in_cache_latest_version + 10 * MAX_REDIS_FETCH_BATCH_SIZE as u64,
in_cache_latest_version + 10 * MAX_FETCH_BATCH_SIZE as u64,
);
let versions_to_fetch = (in_cache_latest_version..end_version).collect();
let transactions = batch_get_transactions(&mut conn, versions_to_fetch, storage_format)
Expand Down

0 comments on commit 2d60c78

Please sign in to comment.