Skip to content

Commit 64c4d1f

Browse files
starknet_patricia_storage: dont keep track of reads for stats
1 parent 8fa4655 commit 64c4d1f

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

crates/starknet_patricia_storage/src/map_storage.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ pub struct CachedStorage<S: Storage> {
7676
pub storage: S,
7777
pub cache: LruCache<DbKey, Option<DbValue>>,
7878
pub cache_on_write: bool,
79-
reads: u128,
80-
cached_reads: u128,
8179
writes: u128,
8280
include_inner_stats: bool,
8381
}
@@ -204,8 +202,6 @@ impl<S: Storage> CachedStorage<S> {
204202
storage,
205203
cache: LruCache::new(config.cache_size),
206204
cache_on_write: config.cache_on_write,
207-
reads: 0,
208-
cached_reads: 0,
209205
writes: 0,
210206
include_inner_stats: config.include_inner_stats,
211207
}
@@ -217,14 +213,6 @@ impl<S: Storage> CachedStorage<S> {
217213
}
218214
}
219215

220-
pub fn total_reads(&self) -> u128 {
221-
self.reads
222-
}
223-
224-
pub fn total_cached_reads(&self) -> u128 {
225-
self.cached_reads
226-
}
227-
228216
pub fn total_writes(&self) -> u128 {
229217
self.writes
230218
}
@@ -235,9 +223,7 @@ impl<S: Storage> Storage for CachedStorage<S> {
235223
type Config = CachedStorageConfig<S::Config>;
236224

237225
async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
238-
self.reads += 1;
239226
if let Some(cached_value) = self.cache.get(key) {
240-
self.cached_reads += 1;
241227
return Ok(cached_value.clone());
242228
}
243229

@@ -267,10 +253,6 @@ impl<S: Storage> Storage for CachedStorage<S> {
267253
}
268254
}
269255

270-
self.reads += u128::try_from(keys.len()).expect("usize should fit in u128");
271-
self.cached_reads +=
272-
u128::try_from(keys.len() - keys_to_fetch.len()).expect("usize should fit in u128");
273-
274256
let fetched_values = self.storage.mget(keys_to_fetch.as_slice()).await?;
275257
indices_to_fetch.iter().zip(keys_to_fetch).zip(fetched_values).for_each(
276258
|((index, key), value)| {
@@ -297,9 +279,10 @@ impl<S: Storage> Storage for CachedStorage<S> {
297279
}
298280

299281
fn get_stats(&self) -> PatriciaStorageResult<Self::Stats> {
282+
// TODO(Nimrod): Don't return dummy values for reads and cached reads.
300283
Ok(CachedStorageStats {
301-
reads: self.reads,
302-
cached_reads: self.cached_reads,
284+
reads: 0,
285+
cached_reads: 0,
303286
writes: self.writes,
304287
inner_stats: if self.include_inner_stats {
305288
Some(self.storage.get_stats()?)
@@ -310,8 +293,6 @@ impl<S: Storage> Storage for CachedStorage<S> {
310293
}
311294

312295
fn reset_stats(&mut self) -> PatriciaStorageResult<()> {
313-
self.reads = 0;
314-
self.cached_reads = 0;
315296
self.writes = 0;
316297
self.storage.reset_stats()
317298
}

0 commit comments

Comments
 (0)