mirror of
https://github.com/facebook/rocksdb.git
synced 2026-10-23 08:09:02 +03:00
Summary: Solaris support was contributed by outside users starting withd78c6b28c(2016), and no project CI has ever run on Solaris. The last Solaris-motivated change wasc76688745(https://github.com/facebook/rocksdb/issues/4012, June 2018). Four months later,d6ec28870(https://github.com/facebook/rocksdb/issues/4226, 5.18) gave PerfContext a user-declared destructor while the Solaris-only definition was still `__thread PerfContext perf_context_`, which GCC rejects, so the Solaris build has not compiled since.fd00f39f9(https://github.com/facebook/rocksdb/issues/8117, 2021) then renamed that definition to `perf_context` while keeping `#define perf_context (*get_perf_context())` in perf_context_imp.h, so the definition expands to `thread_local PerfContext (*get_perf_context());`, an error still present today. The Solaris-only paths are dead and untestable, yet still attract new carve-outs. Because Solaris support is apparently unused and complicating things, this change removes all OS_SOLARIS / SunOS handling from the build (Make, CMake, build_detect_platform, INSTALL.md), the portability layer and Env (endianness, gethrtime, directio, stack trace), the perf_context macro and destructor carve-out, Solaris-only test workarounds and exclusions, and RocksJava's Environment.isSolaris() and Solaris JNI library naming. Not Solaris-specific and kept: SPARC unaligned-access handling in util/coding.h, sparc64 in Makefile machine lists (Linux/OpenBSD), and sparcv9 in RocksJava Environment.is64Bit(). Third-party sources are untouched. Pull Request resolved: https://github.com/facebook/rocksdb/pull/15449 Test Plan: On non-Solaris platforms every removed condition was either an OS_SOLARIS-only branch or a `!defined(OS_SOLARIS)` term that was always true, so the code compiled is unchanged and the CI matrix covers it. The Solaris breakage was confirmed by syntax-checking monitoring/perf_context.cc with -DOS_SOLARIS (GCC 11, stub sys/isa_defs.h) at each commit touching the perf_context files fromc31979205throughfd00f39f9: clean befored6ec28870, failing at every commit fromd6ec28870on. Reviewed By: archang19 Differential Revision: D126714985 Pulled By: pdillinger fbshipit-source-id: 40d22fcd5a462375c9d2c93f52407df651286ef7
117 lines
4.8 KiB
C++
117 lines
4.8 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
//
|
|
#pragma once
|
|
#include "monitoring/perf_step_timer.h"
|
|
#include "port/likely.h"
|
|
#include "rocksdb/perf_context.h"
|
|
#include "util/stop_watch.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
#if defined(NPERF_CONTEXT)
|
|
extern PerfContext perf_context;
|
|
#else
|
|
extern thread_local PerfContext perf_context;
|
|
#endif
|
|
|
|
#if !defined(NPERF_CONTEXT)
|
|
// PerfContext has a non-trivial destructor, so each access to `perf_context`
|
|
// from another file calls its TLS init function. The macros below read this
|
|
// constant-initialized pointer instead.
|
|
extern thread_local constinit PerfContext* perf_context_fast_ptr;
|
|
PerfContext* InitPerfContextFastPtr();
|
|
|
|
inline PerfContext& GetPerfContextFast() {
|
|
PerfContext* ctx = perf_context_fast_ptr;
|
|
if (UNLIKELY(ctx == nullptr)) {
|
|
ctx = InitPerfContextFastPtr();
|
|
}
|
|
return *ctx;
|
|
}
|
|
#endif
|
|
|
|
#if defined(NPERF_CONTEXT)
|
|
|
|
#define PERF_TIMER_STOP(metric)
|
|
#define PERF_TIMER_START(metric)
|
|
#define PERF_TIMER_GUARD(metric)
|
|
#define PERF_TIMER_GUARD_WITH_CLOCK(metric, clock)
|
|
#define PERF_CPU_TIMER_GUARD(metric, clock)
|
|
#define PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(metric, condition, stats, \
|
|
ticker_type)
|
|
#define PERF_TIMER_FOR_WAIT_GUARD(metric)
|
|
#define PERF_TIMER_MEASURE(metric)
|
|
#define PERF_COUNTER_ADD(metric, value)
|
|
#define PERF_COUNTER_BY_LEVEL_ADD(metric, value, level)
|
|
|
|
#else
|
|
|
|
// Stop the timer and update the metric
|
|
#define PERF_TIMER_STOP(metric) perf_step_timer_##metric.Stop();
|
|
|
|
#define PERF_TIMER_START(metric) perf_step_timer_##metric.Start();
|
|
|
|
// Declare and set start time of the timer
|
|
#define PERF_TIMER_GUARD(metric) \
|
|
PerfStepTimer perf_step_timer_##metric(&(GetPerfContextFast().metric)); \
|
|
perf_step_timer_##metric.Start();
|
|
|
|
// Declare and set start time of the timer
|
|
#define PERF_TIMER_GUARD_WITH_CLOCK(metric, clock) \
|
|
PerfStepTimer perf_step_timer_##metric(&(GetPerfContextFast().metric), \
|
|
clock); \
|
|
perf_step_timer_##metric.Start();
|
|
|
|
// Declare and set start time of the timer
|
|
#define PERF_CPU_TIMER_GUARD(metric, clock) \
|
|
PerfStepTimer perf_step_timer_##metric( \
|
|
&(GetPerfContextFast().metric), clock, true, \
|
|
PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \
|
|
perf_step_timer_##metric.Start();
|
|
|
|
#define PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(metric, condition, stats, \
|
|
ticker_type) \
|
|
PerfStepTimer perf_step_timer_##metric( \
|
|
&(GetPerfContextFast().metric), nullptr, false, PerfLevel::kEnableTime, \
|
|
stats, ticker_type); \
|
|
if (condition) { \
|
|
perf_step_timer_##metric.Start(); \
|
|
}
|
|
|
|
#define PERF_TIMER_FOR_WAIT_GUARD(metric) \
|
|
PerfStepTimer perf_step_timer_##metric( \
|
|
&(GetPerfContextFast().metric), nullptr, false, PerfLevel::kEnableWait); \
|
|
perf_step_timer_##metric.Start();
|
|
|
|
// Update metric with time elapsed since last START. start time is reset
|
|
// to current timestamp.
|
|
#define PERF_TIMER_MEASURE(metric) perf_step_timer_##metric.Measure();
|
|
|
|
// Increase metric value
|
|
#define PERF_COUNTER_ADD(metric, value) \
|
|
if (perf_level >= PerfLevel::kEnableCount) { \
|
|
GetPerfContextFast().metric += value; \
|
|
} \
|
|
static_assert(true, "semicolon required")
|
|
|
|
// Increase metric value
|
|
#define PERF_COUNTER_BY_LEVEL_ADD(metric, value, level) \
|
|
if (perf_level >= PerfLevel::kEnableCount && \
|
|
GetPerfContextFast().per_level_perf_context_enabled && \
|
|
GetPerfContextFast().level_to_perf_context) { \
|
|
if ((*(GetPerfContextFast().level_to_perf_context)).find(level) != \
|
|
(*(GetPerfContextFast().level_to_perf_context)).end()) { \
|
|
(*(GetPerfContextFast().level_to_perf_context))[level].metric += value; \
|
|
} else { \
|
|
PerfContextByLevel empty_context; \
|
|
(*(GetPerfContextFast().level_to_perf_context))[level] = empty_context; \
|
|
(*(GetPerfContextFast().level_to_perf_context))[level].metric += value; \
|
|
} \
|
|
}
|
|
|
|
#endif
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|