mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-01 18:56:00 +08:00
Add bytes_per_second unit in histograms
This commit is contained in:
parent
8343c78bf0
commit
4a0fa57989
@ -311,7 +311,7 @@ public:
|
|||||||
bytes(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, FETCH_KEYS_BYTES_HISTOGRAM,
|
bytes(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, FETCH_KEYS_BYTES_HISTOGRAM,
|
||||||
Histogram::Unit::bytes)),
|
Histogram::Unit::bytes)),
|
||||||
bandwidth(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, FETCH_KEYS_BYTES_PER_SECOND_HISTOGRAM,
|
bandwidth(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, FETCH_KEYS_BYTES_PER_SECOND_HISTOGRAM,
|
||||||
Histogram::Unit::bytes)) {}
|
Histogram::Unit::bytes_per_second)) {}
|
||||||
} fetchKeysHistograms;
|
} fetchKeysHistograms;
|
||||||
|
|
||||||
class CurrentRunningFetchKeys {
|
class CurrentRunningFetchKeys {
|
||||||
|
@ -41,6 +41,8 @@ thread_local ISimulator::ProcessInfo* ISimulator::currentProcess = nullptr;
|
|||||||
// we have a simulated contex here; we'd just use the current context regardless.
|
// we have a simulated contex here; we'd just use the current context regardless.
|
||||||
static HistogramRegistry* globalHistograms = nullptr;
|
static HistogramRegistry* globalHistograms = nullptr;
|
||||||
|
|
||||||
|
#pragma region HistogramRegistry
|
||||||
|
|
||||||
HistogramRegistry& GetHistogramRegistry() {
|
HistogramRegistry& GetHistogramRegistry() {
|
||||||
ISimulator::ProcessInfo* info = g_simulator.getCurrentProcess();
|
ISimulator::ProcessInfo* info = g_simulator.getCurrentProcess();
|
||||||
|
|
||||||
@ -89,6 +91,16 @@ void HistogramRegistry::logReport() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion // HistogramRegistry
|
||||||
|
|
||||||
|
#pragma region Histogram
|
||||||
|
|
||||||
|
const std::unordered_map<Histogram::Unit, std::string> Histogram::UnitToStringMapper = {
|
||||||
|
{ Histogram::Unit::microseconds, "microseconds" },
|
||||||
|
{ Histogram::Unit::bytes, "bytes" },
|
||||||
|
{ Histogram::Unit::bytes_per_second, "bytes_per_second" }
|
||||||
|
};
|
||||||
|
|
||||||
void Histogram::writeToLog() {
|
void Histogram::writeToLog() {
|
||||||
bool active = false;
|
bool active = false;
|
||||||
for (uint32_t i = 0; i < 32; i++) {
|
for (uint32_t i = 0; i < 32; i++) {
|
||||||
@ -102,17 +114,19 @@ void Histogram::writeToLog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TraceEvent e(SevInfo, "Histogram");
|
TraceEvent e(SevInfo, "Histogram");
|
||||||
e.detail("Group", group).detail("Op", op);
|
e.detail("Group", group).detail("Op", op).detail("Unit", UnitToStringMapper.at(unit));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 32; i++) {
|
for (uint32_t i = 0; i < 32; i++) {
|
||||||
|
uint32_t value = ((uint32_t)1) << (i + 1);
|
||||||
|
|
||||||
if (buckets[i]) {
|
if (buckets[i]) {
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case Unit::microseconds: {
|
case Unit::microseconds:
|
||||||
uint32_t usec = ((uint32_t)1) << (i + 1);
|
e.detail(format("LessThan%u.%03u", value / 1000, value % 1000), buckets[i]);
|
||||||
e.detail(format("LessThan%u.%03u", usec / 1000, usec % 1000), buckets[i]);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case Unit::bytes:
|
case Unit::bytes:
|
||||||
e.detail(format("LessThan%u", ((uint32_t)1) << (i + 1)), buckets[i]);
|
case Unit::bytes_per_second:
|
||||||
|
e.detail(format("LessThan%u", value), buckets[i]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
@ -121,6 +135,8 @@ void Histogram::writeToLog() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion // Histogram
|
||||||
|
|
||||||
TEST_CASE("/flow/histogram/smoke_test") {
|
TEST_CASE("/flow/histogram/smoke_test") {
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -168,4 +184,4 @@ TEST_CASE("/flow/histogram/smoke_test") {
|
|||||||
GetHistogramRegistry().logReport();
|
GetHistogramRegistry().logReport();
|
||||||
|
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
@ -57,11 +58,16 @@ HistogramRegistry& GetHistogramRegistry();
|
|||||||
*/
|
*/
|
||||||
class Histogram sealed : public ReferenceCounted<Histogram> {
|
class Histogram sealed : public ReferenceCounted<Histogram> {
|
||||||
public:
|
public:
|
||||||
enum class Unit { microseconds, bytes };
|
enum class Unit { microseconds, bytes, bytes_per_second };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::unordered_map<Unit, std::string> UnitToStringMapper;
|
||||||
|
|
||||||
Histogram(std::string group, std::string op, Unit unit, HistogramRegistry& registry)
|
Histogram(std::string group, std::string op, Unit unit, HistogramRegistry& registry)
|
||||||
: group(group), op(op), unit(unit), registry(registry), ReferenceCounted<Histogram>() {
|
: group(group), op(op), unit(unit), registry(registry), ReferenceCounted<Histogram>() {
|
||||||
|
|
||||||
|
ASSERT(UnitToStringMapper.find(unit) != UnitToStringMapper.end());
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user