@@ -30,14 +30,10 @@ fn path_to_windows_str<T: AsRef<OsStr>>(path: &T) -> Vec<u16> {
3030 path. as_ref ( ) . encode_wide ( ) . chain ( Some ( 0 ) ) . collect ( )
3131}
3232
33- // The number of read/write/remove/list operations after which we clean up our `locks` HashMap.
34- const GC_LOCK_INTERVAL : usize = 25 ;
35-
3633/// A [`KVStoreSync`] implementation that writes to and reads from the file system.
3734pub struct FilesystemStore {
3835 data_dir : PathBuf ,
3936 tmp_file_counter : AtomicUsize ,
40- gc_counter : AtomicUsize ,
4137
4238 // Per path lock that ensures that we don't have concurrent writes to the same file. The lock also encapsulates the
4339 // latest written version per key.
@@ -49,27 +45,14 @@ impl FilesystemStore {
4945 pub fn new ( data_dir : PathBuf ) -> Self {
5046 let locks = Mutex :: new ( HashMap :: new ( ) ) ;
5147 let tmp_file_counter = AtomicUsize :: new ( 0 ) ;
52- let gc_counter = AtomicUsize :: new ( 1 ) ;
53- Self { data_dir, tmp_file_counter, gc_counter, locks }
48+ Self { data_dir, tmp_file_counter, locks }
5449 }
5550
5651 /// Returns the data directory.
5752 pub fn get_data_dir ( & self ) -> PathBuf {
5853 self . data_dir . clone ( )
5954 }
6055
61- fn garbage_collect_locks ( & self ) {
62- let gc_counter = self . gc_counter . fetch_add ( 1 , Ordering :: AcqRel ) ;
63-
64- if gc_counter % GC_LOCK_INTERVAL == 0 {
65- // Take outer lock for the cleanup.
66- let mut outer_lock = self . locks . lock ( ) . unwrap ( ) ;
67-
68- // Garbage collect all lock entries that are not referenced anymore.
69- outer_lock. retain ( |_, v| Arc :: strong_count ( & v) > 1 ) ;
70- }
71- }
72-
7356 fn get_dest_dir_path (
7457 & self , primary_namespace : & str , secondary_namespace : & str ,
7558 ) -> std:: io:: Result < PathBuf > {
@@ -190,8 +173,6 @@ impl FilesystemStore {
190173 }
191174 } ;
192175
193- self . garbage_collect_locks ( ) ;
194-
195176 res
196177 }
197178}
@@ -217,8 +198,6 @@ impl KVStoreSync for FilesystemStore {
217198 f. read_to_end ( & mut buf) ?;
218199 }
219200
220- self . garbage_collect_locks ( ) ;
221-
222201 Ok ( buf)
223202 }
224203
@@ -318,8 +297,6 @@ impl KVStoreSync for FilesystemStore {
318297 }
319298 }
320299
321- self . garbage_collect_locks ( ) ;
322-
323300 Ok ( ( ) )
324301 }
325302
@@ -348,8 +325,6 @@ impl KVStoreSync for FilesystemStore {
348325 keys. push ( key) ;
349326 }
350327
351- self . garbage_collect_locks ( ) ;
352-
353328 Ok ( keys)
354329 }
355330}
0 commit comments