mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 11:52:27 +00:00
Taming query profiler
This commit is contained in:
parent
d6a09a6efa
commit
3142921bb4
@ -316,6 +316,7 @@ The server successfully detected this situation and will download merged part fr
|
|||||||
\
|
\
|
||||||
M(CannotWriteToWriteBufferDiscard, "Number of stack traces dropped by query profiler or signal handler because pipe is full or cannot write to pipe.") \
|
M(CannotWriteToWriteBufferDiscard, "Number of stack traces dropped by query profiler or signal handler because pipe is full or cannot write to pipe.") \
|
||||||
M(QueryProfilerSignalOverruns, "Number of times we drop processing of a query profiler signal due to overrun plus the number of signals that OS has not delivered due to overrun.") \
|
M(QueryProfilerSignalOverruns, "Number of times we drop processing of a query profiler signal due to overrun plus the number of signals that OS has not delivered due to overrun.") \
|
||||||
|
M(QueryProfilerConcurrencyOverruns, "Number of times we drop processing of a query profiler signal due to too many concurrent query profilers in other threads, which may indicate overload.") \
|
||||||
M(QueryProfilerRuns, "Number of times QueryProfiler had been run.") \
|
M(QueryProfilerRuns, "Number of times QueryProfiler had been run.") \
|
||||||
\
|
\
|
||||||
M(CreatedLogEntryForMerge, "Successfully created log entry to merge parts in ReplicatedMergeTree.") \
|
M(CreatedLogEntryForMerge, "Successfully created log entry to merge parts in ReplicatedMergeTree.") \
|
||||||
|
@ -22,6 +22,7 @@ namespace CurrentMetrics
|
|||||||
namespace ProfileEvents
|
namespace ProfileEvents
|
||||||
{
|
{
|
||||||
extern const Event QueryProfilerSignalOverruns;
|
extern const Event QueryProfilerSignalOverruns;
|
||||||
|
extern const Event QueryProfilerConcurrencyOverruns;
|
||||||
extern const Event QueryProfilerRuns;
|
extern const Event QueryProfilerRuns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +41,19 @@ namespace
|
|||||||
/// to ignore delivered signals after timer_delete().
|
/// to ignore delivered signals after timer_delete().
|
||||||
thread_local bool signal_handler_disarmed = true;
|
thread_local bool signal_handler_disarmed = true;
|
||||||
|
|
||||||
|
/// Don't permit too many threads be busy inside profiler,
|
||||||
|
/// which could slow down the system in some environments.
|
||||||
|
std::atomic<Int64> concurrent_invocations = 0;
|
||||||
|
|
||||||
void writeTraceInfo(TraceType trace_type, int /* sig */, siginfo_t * info, void * context)
|
void writeTraceInfo(TraceType trace_type, int /* sig */, siginfo_t * info, void * context)
|
||||||
{
|
{
|
||||||
|
SCOPE_EXIT({ concurrent_invocations.fetch_sub(1, std::memory_order_relaxed); });
|
||||||
|
if (concurrent_invocations.fetch_add(1, std::memory_order_relaxed) > 100)
|
||||||
|
{
|
||||||
|
ProfileEvents::incrementNoTrace(ProfileEvents::QueryProfilerConcurrencyOverruns);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto saved_errno = errno; /// We must restore previous value of errno in signal handler.
|
auto saved_errno = errno; /// We must restore previous value of errno in signal handler.
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
|
Loading…
Reference in New Issue
Block a user