Record the number of open db iterators.

Summary: Enhance the statitics to report the number of open db iterators.

Test Plan: make check

Reviewers: haobo, emayanke

Reviewed By: emayanke

CC: leveldb

Differential Revision: https://reviews.facebook.net/D10983
main
Dhruba Borthakur 12 years ago
parent fb684da082
commit a8d807ee91
  1. 8
      db/db_iter.cc
  2. 3
      include/leveldb/statistics.h

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors. // found in the LICENSE file. See the AUTHORS file for names of contributors.
#include <stdexcept>
#include "db/db_iter.h" #include "db/db_iter.h"
#include <stdexcept>
#include "db/filename.h" #include "db/filename.h"
#include "db/dbformat.h" #include "db/dbformat.h"
@ -61,9 +61,12 @@ class DBIter: public Iterator {
sequence_(s), sequence_(s),
direction_(kForward), direction_(kForward),
valid_(false), valid_(false),
current_entry_is_merged_(false) { current_entry_is_merged_(false),
statistics_(options.statistics) {
RecordTick(statistics_, NO_ITERATORS, 1);
} }
virtual ~DBIter() { virtual ~DBIter() {
RecordTick(statistics_, NO_ITERATORS, -1);
delete iter_; delete iter_;
} }
virtual bool Valid() const { return valid_; } virtual bool Valid() const { return valid_; }
@ -124,6 +127,7 @@ class DBIter: public Iterator {
Direction direction_; Direction direction_;
bool valid_; bool valid_;
bool current_entry_is_merged_; bool current_entry_is_merged_;
std::shared_ptr<Statistics> statistics_;
// No copying allowed // No copying allowed
DBIter(const DBIter&); DBIter(const DBIter&);

@ -47,7 +47,8 @@ enum Tickers {
// write throttle because of too many files in L0 // write throttle because of too many files in L0
STALL_L0_NUM_FILES_MICROS = 15, STALL_L0_NUM_FILES_MICROS = 15,
RATE_LIMIT_DELAY_MILLIS = 16, RATE_LIMIT_DELAY_MILLIS = 16,
TICKER_ENUM_MAX = 17 NO_ITERATORS = 17, // number of iterators currently open
TICKER_ENUM_MAX = 18
}; };

Loading…
Cancel
Save