File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 5
5
crate :: { accounts_hash:: CalculateHashIntermediate , cache_hash_data_stats:: CacheHashDataStats } ,
6
6
bytemuck_derive:: { Pod , Zeroable } ,
7
7
memmap2:: MmapMut ,
8
- solana_measure:: measure:: Measure ,
8
+ solana_measure:: { measure:: Measure , measure_us } ,
9
9
solana_sdk:: clock:: Slot ,
10
10
std:: {
11
11
collections:: HashSet ,
@@ -371,10 +371,17 @@ impl CacheHashData {
371
371
} ) ;
372
372
assert_eq ! ( i, entries) ;
373
373
m2. stop ( ) ;
374
+ // We must flush the mmap after writing, since we're about to turn around and load it for
375
+ // reading *not* via the mmap. If the mmap is never flushed to disk, it is possible the
376
+ // entries will *not* be visible when the reader comes along.
377
+ let ( _, measure_flush_us) = measure_us ! ( cache_file. mmap. flush( ) ?) ;
378
+ m. stop ( ) ;
374
379
self . stats
375
380
. write_to_mmap_us
376
381
. fetch_add ( m2. as_us ( ) , Ordering :: Relaxed ) ;
377
- m. stop ( ) ;
382
+ self . stats
383
+ . flush_mmap_us
384
+ . fetch_add ( measure_flush_us, Ordering :: Relaxed ) ;
378
385
self . stats . save_us . fetch_add ( m. as_us ( ) , Ordering :: Relaxed ) ;
379
386
self . stats . saved_to_cache . fetch_add ( 1 , Ordering :: Relaxed ) ;
380
387
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pub struct CacheHashDataStats {
11
11
pub save_us : AtomicU64 ,
12
12
pub saved_to_cache : AtomicUsize ,
13
13
pub write_to_mmap_us : AtomicU64 ,
14
+ pub flush_mmap_us : AtomicU64 ,
14
15
pub create_save_us : AtomicU64 ,
15
16
pub load_us : AtomicU64 ,
16
17
pub read_us : AtomicU64 ,
@@ -61,6 +62,11 @@ impl CacheHashDataStats {
61
62
self . write_to_mmap_us. load( Ordering :: Relaxed ) ,
62
63
i64
63
64
) ,
65
+ (
66
+ "flush_mmap_us" ,
67
+ self . flush_mmap_us. load( Ordering :: Relaxed ) ,
68
+ i64
69
+ ) ,
64
70
(
65
71
"create_save_us" ,
66
72
self . create_save_us. load( Ordering :: Relaxed ) ,
You can’t perform that action at this time.
0 commit comments