summaryrefslogtreecommitdiff
path: root/util/histogram.cc
diff options
context:
space:
mode:
authorgabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-08-22 21:08:51 +0000
committergabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-08-22 21:08:51 +0000
commite3584f9c28833ec0530b39540ffd406ee41dbc3a (patch)
treee68d1bb6e1e2ad1c2a9acfa6ae26cf2d691055e7 /util/histogram.cc
parentab323f7e1ec53749653967e7d6a2fa1c922334f2 (diff)
downloadleveldb-e3584f9c28833ec0530b39540ffd406ee41dbc3a.tar.gz
Bugfix for issue 33; reduce lock contention in Get(), parallel benchmarks.
- Fix for issue 33 (non-null-terminated result from leveldb_property_value()) - Support for running multiple instances of a benchmark in parallel. - Reduce lock contention on Get(): (1) Do not hold the lock while searching memtables. (2) Shard block and table caches 16-ways. Benchmark for evaluating this change: $ db_bench --benchmarks=fillseq1,readrandom --threads=$n (fillseq1 is a small hack to make sure fillseq runs once regardless of number of threads specified on the command line). git-svn-id: https://leveldb.googlecode.com/svn/trunk@49 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'util/histogram.cc')
-rw-r--r--util/histogram.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/histogram.cc b/util/histogram.cc
index c5178ef..12ec3cf 100644
--- a/util/histogram.cc
+++ b/util/histogram.cc
@@ -55,6 +55,17 @@ void Histogram::Add(double value) {
sum_squares_ += (value * value);
}
+void Histogram::Merge(const Histogram& other) {
+ if (other.min_ < min_) min_ = other.min_;
+ if (other.max_ > max_) max_ = other.max_;
+ num_ += other.num_;
+ sum_ += other.sum_;
+ sum_squares_ += other.sum_squares_;
+ for (int b = 0; b < kNumBuckets; b++) {
+ buckets_[b] += other.buckets_[b];
+ }
+}
+
double Histogram::Median() const {
return Percentile(50.0);
}