@@ -67,8 +67,6 @@ pub struct CachedStorage<S: Storage> {
6767 pub storage : S ,
6868 pub cache : Cache < DbKey , Option < DbValue > > ,
6969 pub cache_on_write : bool ,
70- reads : u128 ,
71- cached_reads : u128 ,
7270 writes : u128 ,
7371 include_inner_stats : bool ,
7472}
@@ -136,8 +134,6 @@ impl<S: Storage> CachedStorage<S> {
136134 storage,
137135 cache : Cache :: builder ( ) . max_capacity ( config. cache_size ) . build ( ) ,
138136 cache_on_write : config. cache_on_write ,
139- reads : 0 ,
140- cached_reads : 0 ,
141137 writes : 0 ,
142138 include_inner_stats : config. include_inner_stats ,
143139 }
@@ -149,14 +145,6 @@ impl<S: Storage> CachedStorage<S> {
149145 }
150146 }
151147
152- pub fn total_reads ( & self ) -> u128 {
153- self . reads
154- }
155-
156- pub fn total_cached_reads ( & self ) -> u128 {
157- self . cached_reads
158- }
159-
160148 pub fn total_writes ( & self ) -> u128 {
161149 self . writes
162150 }
@@ -168,9 +156,7 @@ impl<S: Storage> Storage for CachedStorage<S> {
168156 type Config = EmptyStorageConfig ;
169157
170158 async fn get ( & mut self , key : & DbKey ) -> PatriciaStorageResult < Option < DbValue > > {
171- self . reads += 1 ;
172159 if let Some ( cached_value) = self . cache . get ( key) {
173- self . cached_reads += 1 ;
174160 return Ok ( cached_value) ;
175161 }
176162
@@ -200,10 +186,6 @@ impl<S: Storage> Storage for CachedStorage<S> {
200186 }
201187 }
202188
203- self . reads += u128:: try_from ( keys. len ( ) ) . expect ( "usize should fit in u128" ) ;
204- self . cached_reads +=
205- u128:: try_from ( keys. len ( ) - keys_to_fetch. len ( ) ) . expect ( "usize should fit in u128" ) ;
206-
207189 let fetched_values = self . storage . mget ( keys_to_fetch. as_slice ( ) ) . await ?;
208190 indices_to_fetch. iter ( ) . zip ( keys_to_fetch) . zip ( fetched_values) . for_each (
209191 |( ( index, key) , value) | {
@@ -230,9 +212,10 @@ impl<S: Storage> Storage for CachedStorage<S> {
230212 }
231213
232214 fn get_stats ( & self ) -> PatriciaStorageResult < Self :: Stats > {
215+ // TODO(Nimrod): Don't return dummy values for reads and cached reads.
233216 Ok ( CachedStorageStats {
234- reads : self . reads ,
235- cached_reads : self . cached_reads ,
217+ reads : 0 ,
218+ cached_reads : 0 ,
236219 writes : self . writes ,
237220 inner_stats : if self . include_inner_stats {
238221 Some ( self . storage . get_stats ( ) ?)
@@ -243,8 +226,6 @@ impl<S: Storage> Storage for CachedStorage<S> {
243226 }
244227
245228 fn reset_stats ( & mut self ) -> PatriciaStorageResult < ( ) > {
246- self . reads = 0 ;
247- self . cached_reads = 0 ;
248229 self . writes = 0 ;
249230 self . storage . reset_stats ( )
250231 }
0 commit comments