@@ -411,14 +411,28 @@ _u64 Index<T, TagT, LabelT>::save_delete_list(const std::string& filename) const
411
411
}
412
412
413
413
template <typename T, typename TagT, typename LabelT>
414
- void Index<T, TagT, LabelT>::save(const char *filename, bool compact_before_save)
414
+ void Index<T, TagT, LabelT>::save(const char *filename, bool compact_before_save /* = false */ )
415
+ {
416
+ save (filename, compact_before_save, false );
417
+ }
418
+
419
+ template <typename T, typename TagT, typename LabelT>
420
+ void Index<T, TagT, LabelT>::save(const char *filename, bool compact_before_save, bool no_lock)
415
421
{
416
422
diskann::Timer timer;
417
423
418
- std::unique_lock<std::shared_timed_mutex> ul (_update_lock);
419
- std::unique_lock<std::shared_timed_mutex> cl (_consolidate_lock);
420
- std::unique_lock<std::shared_timed_mutex> tl (_tag_lock);
421
- std::unique_lock<std::shared_timed_mutex> dl (_delete_lock);
424
+ std::unique_lock<std::shared_timed_mutex> ul (_update_lock, std::defer_lock);
425
+ std::unique_lock<std::shared_timed_mutex> cl (_consolidate_lock, std::defer_lock);
426
+ std::unique_lock<std::shared_timed_mutex> tl (_tag_lock, std::defer_lock);
427
+ std::unique_lock<std::shared_timed_mutex> dl (_delete_lock, std::defer_lock);
428
+
429
+ if (!no_lock)
430
+ {
431
+ ul.lock ();
432
+ cl.lock ();
433
+ tl.lock ();
434
+ dl.lock ();
435
+ }
422
436
423
437
bool frozen_points_compacted = false ;
424
438
if (compact_before_save)
0 commit comments