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
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include <stdexcept>
#include "db/db_iter.h"
#include <stdexcept>
#include "db/filename.h"
#include "db/dbformat.h"
@ -61,9 +61,12 @@ class DBIter: public Iterator {
sequence_(s),
direction_(kForward),
valid_(false),
current_entry_is_merged_(false) {
current_entry_is_merged_(false),
statistics_(options.statistics) {
RecordTick(statistics_, NO_ITERATORS, 1);
}
virtual ~DBIter() {
RecordTick(statistics_, NO_ITERATORS, -1);
delete iter_;
}
virtual bool Valid() const { return valid_; }
@ -124,6 +127,7 @@ class DBIter: public Iterator {
Direction direction_;
bool valid_;
bool current_entry_is_merged_;
std::shared_ptr<Statistics> statistics_;
// No copying allowed
DBIter(const DBIter&);

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

Loading…
Cancel
Save