From e70ba4e40e3ff515902c507a54fe818ac4e915ec Mon Sep 17 00:00:00 2001 From: sdong Date: Fri, 8 Jul 2016 12:51:24 -0700 Subject: [PATCH] MemTable::PostProcess() can skip updating num_deletes if the delta is 0 Summary: In many use cases there is no deletes. No need to pay the overhead of atomically updating num_deletes. Test Plan: Run existing test. Reviewers: ngbronson, yiwu, andrewkr, igor Reviewed By: andrewkr Subscribers: leveldb, andrewkr, dhruba Differential Revision: https://reviews.facebook.net/D60555 --- db/memtable.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/memtable.h b/db/memtable.h index d6d2a735f..40a02ea41 100644 --- a/db/memtable.h +++ b/db/memtable.h @@ -232,8 +232,10 @@ class MemTable { num_entries_.fetch_add(update_counters.num_entries, std::memory_order_relaxed); data_size_.fetch_add(update_counters.data_size, std::memory_order_relaxed); - num_deletes_.fetch_add(update_counters.num_deletes, - std::memory_order_relaxed); + if (update_counters.num_deletes != 0) { + num_deletes_.fetch_add(update_counters.num_deletes, + std::memory_order_relaxed); + } UpdateFlushState(); }