mirror of
https://github.com/facebook/rocksdb.git
synced 2024-12-03 05:54:17 +00:00
d9dd2a1926
Summary: As title. No locking/atomic is needed due to thread local. There is also no need to modify the existing client interface, in order to expose related counters. perf_context_test shows a simple example of retrieving the number of user key comparison done for each put and get call. More counters could be added later. Sample output ./perf_context_test 1000000 ==== Test PerfContextTest.KeyComparisonCount Inserting 1000000 key/value pairs ... total user key comparison get: 43446523 total user key comparison put: 8017877 max user key comparison get: 88939 avg user key comparison get:43 Basically, the current skiplist does well on average, but could perform poorly in extreme cases. Test Plan: run perf_context_test <total number of entries to put/get> Reviewers: dhruba Differential Revision: https://reviews.facebook.net/D12225
25 lines
450 B
C++
25 lines
450 B
C++
#ifndef STORAGE_LEVELDB_INCLUDE_PERF_CONTEXT_H
|
|
#define STORAGE_LEVELDB_INCLUDE_PERF_CONTEXT_H
|
|
|
|
#include <stdint.h>
|
|
|
|
namespace leveldb {
|
|
|
|
// A thread local context for gathering performance counter efficiently
|
|
// and transparently.
|
|
|
|
struct PerfContext {
|
|
|
|
void Reset(); // reset all performance counters to zero
|
|
|
|
|
|
uint64_t user_key_comparison_count; // total number of user key comparisons
|
|
};
|
|
|
|
extern __thread PerfContext perf_context;
|
|
|
|
}
|
|
|
|
|
|
#endif
|