]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Compaction now conditionally boosts the size of deletion entries.
authorYueh-Hsuan Chiang <yhchiang@fb.com>
Tue, 26 May 2015 21:05:38 +0000 (14:05 -0700)
committerIgor Canadi <icanadi@fb.com>
Thu, 11 Jun 2015 22:42:54 +0000 (15:42 -0700)
Summary:
Compaction now boosts the size of deletion entries of a file only when
the number of deletion entries is greater than the number of non-deletion
entries in the file.  The motivation here is that in a stable workload,
the number of deletion entries should be roughly equal to the number of
non-deletion entries.  If we compensate the size of deletion entries in a
stable workload, the deletion compensation logic might introduce unwanted
effet which changes the shape of LSM tree.

Test Plan: db_test --gtest_filter="*Deletion*"

Reviewers: sdong, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D38703

db/version_set.cc

index 9881c3edcc8d10c32de7175b65b04f80981336c4..7cf010a786e32e8edc484947154a51a7742318b0 100644 (file)
@@ -962,9 +962,20 @@ void VersionStorageInfo::ComputeCompensatedSizes() {
       // for files that have been created right now and no other thread has
       // access to them. That's why we can safely mutate compensated_file_size.
       if (file_meta->compensated_file_size == 0) {
-        file_meta->compensated_file_size = file_meta->fd.GetFileSize() +
-            file_meta->num_deletions * average_value_size *
-            kDeletionWeightOnCompaction;
+        file_meta->compensated_file_size = file_meta->fd.GetFileSize();
+        // Here we only boost the size of deletion entries of a file only
+        // when the number of deletion entries is greater than the number of
+        // non-deletion entries in the file.  The motivation here is that in
+        // a stable workload, the number of deletion entries should be roughly
+        // equal to the number of non-deletion entries.  If we compensate the
+        // size of deletion entries in a stable workload, the deletion
+        // compensation logic might introduce unwanted effet which changes the
+        // shape of LSM tree.
+        if (file_meta->num_deletions * 2 >= file_meta->num_entries) {
+          file_meta->compensated_file_size +=
+              (file_meta->num_deletions * 2 - file_meta->num_entries)
+              * average_value_size * kDeletionWeightOnCompaction;
+        }
       }
     }
   }