Skip to content

mv perfcounter disable

Matthew Von-Maszewski edited this page Jun 29, 2015 · 4 revisions

Status

  • merged to master - June 18, 2015
  • code complete - June 17, 2015
  • development started - June 17, 2015

History / Context

The leveldb performance counters now default to a disabled state. They are enabled when the file "/etc/riak/perf_counters" exists. The content of the file is irrelevant. leveldb's background thread polls for the file once a minute. This allows enabling and disabling the performance counters without restarting leveldb / Riak.

The performance counters allow users and programmers to get a detail view of leveldb's internal activities. But the detail view does have a slight performance cost. The performance cost is larger on NUMA architecture systems than non-NUMA. And extremely few sites make use of the performance counters in production. This branch allows sites to have the best of both worlds: faster performance for normal operations and runtime control of the performance counters during site diagnosis.

Branch Description

All performance counters are now categorized as either discretionary counters or not. This branch disables the discretionary counters by default. The non-discretionary counters never disable. Typically, the most heavily used counters are the discretionary counters. This slightly reduces latencies for user read and write operations.

The throttle thread executes once a minute. It now performs a quick test for the file /etc/riak/perf_counters as part of its cycle. The thread reactivates all discretionary counters while the file exists and disables them in the file's absence ... dynamically.

include/leveldb/perf_counter.h

Previously, the only attribute related to a counter was its text name. This branch adds a flag to mark the counter as discretionary or not. The new structure PerfCounterAttributes holds both of these attributes. The PerformanceCounters class now declares a static array of the PerfCounterAttributes structures instead of an array of only text names.

This file also declares the leveldb global gPerfCountersDisabled. The throttle thread sets / resets this global based upon its test of /etc/riak/perf_counters existence.

util/perf_counter.cc

All performance counter operations, such as Inc() and Dec(), now make a quick test of the global gPerfCountersDisabled flag and the m_PerfDiscretionary flag of the counter in consideration. Based upon the two flags, the counter operation is skipped or executed.

The static array of text names, PerformanceCounters::m_PerfCounterNames[], is replaced by the PerformanceCounters::m_PerfCounterAttr[] static array.

util/throttle.h

This file contains an unrelated clean up. gThreadLock0 and gThreadLock1 declarations have not been necessary in Basho's leveldb for over a year. Now gone.

util/throttle.cc

Like util/throttle.h this file contains one unrelated clean up. gThreadLock0 and gThreadLock1 have not been necessary in Basho's leveldb for over a year. Now gone.

The throttle thread's last action as part of its loop is to test for /etc/riak/perf_counters' existence. The return value from the access() test then sets gPerfCountersDisabled global accordingly.

Clone this wiki locally