@@ -30,14 +30,10 @@ fn path_to_windows_str<T: AsRef<OsStr>>(path: &T) -> Vec<u16> {
30
30
path. as_ref ( ) . encode_wide ( ) . chain ( Some ( 0 ) ) . collect ( )
31
31
}
32
32
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
-
36
33
/// A [`KVStoreSync`] implementation that writes to and reads from the file system.
37
34
pub struct FilesystemStore {
38
35
data_dir : PathBuf ,
39
36
tmp_file_counter : AtomicUsize ,
40
- gc_counter : AtomicUsize ,
41
37
42
38
// Per path lock that ensures that we don't have concurrent writes to the same file. The lock also encapsulates the
43
39
// latest written version per key.
@@ -49,27 +45,14 @@ impl FilesystemStore {
49
45
pub fn new ( data_dir : PathBuf ) -> Self {
50
46
let locks = Mutex :: new ( HashMap :: new ( ) ) ;
51
47
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 }
54
49
}
55
50
56
51
/// Returns the data directory.
57
52
pub fn get_data_dir ( & self ) -> PathBuf {
58
53
self . data_dir . clone ( )
59
54
}
60
55
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
-
73
56
fn get_dest_dir_path (
74
57
& self , primary_namespace : & str , secondary_namespace : & str ,
75
58
) -> std:: io:: Result < PathBuf > {
@@ -190,8 +173,6 @@ impl FilesystemStore {
190
173
}
191
174
} ;
192
175
193
- self . garbage_collect_locks ( ) ;
194
-
195
176
res
196
177
}
197
178
}
@@ -217,8 +198,6 @@ impl KVStoreSync for FilesystemStore {
217
198
f. read_to_end ( & mut buf) ?;
218
199
}
219
200
220
- self . garbage_collect_locks ( ) ;
221
-
222
201
Ok ( buf)
223
202
}
224
203
@@ -318,8 +297,6 @@ impl KVStoreSync for FilesystemStore {
318
297
}
319
298
}
320
299
321
- self . garbage_collect_locks ( ) ;
322
-
323
300
Ok ( ( ) )
324
301
}
325
302
@@ -348,8 +325,6 @@ impl KVStoreSync for FilesystemStore {
348
325
keys. push ( key) ;
349
326
}
350
327
351
- self . garbage_collect_locks ( ) ;
352
-
353
328
Ok ( keys)
354
329
}
355
330
}
0 commit comments