2014-01-03 08:20:13 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Позволяет считать количество различных событий, произошедших в программе
|
|
|
|
|
* - для высокоуровневого профайлинга.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define APPLY_FOR_EVENTS(M) \
|
2014-09-13 18:34:08 +00:00
|
|
|
|
M(Query) \
|
|
|
|
|
M(SelectQuery) \
|
|
|
|
|
M(InsertQuery) \
|
|
|
|
|
M(FileOpen) \
|
|
|
|
|
M(Seek) \
|
|
|
|
|
M(ReadBufferFromFileDescriptorRead) \
|
2015-04-16 12:06:05 +00:00
|
|
|
|
M(ReadBufferFromFileDescriptorReadBytes) \
|
|
|
|
|
M(WriteBufferFromFileDescriptorWrite) \
|
|
|
|
|
M(WriteBufferFromFileDescriptorWriteBytes) \
|
|
|
|
|
M(ReadBufferAIORead) \
|
|
|
|
|
M(ReadBufferAIOReadBytes) \
|
|
|
|
|
M(WriteBufferAIOWrite) \
|
|
|
|
|
M(WriteBufferAIOWriteBytes) \
|
2014-09-13 18:34:08 +00:00
|
|
|
|
M(ReadCompressedBytes) \
|
|
|
|
|
M(CompressedReadBufferBlocks) \
|
|
|
|
|
M(CompressedReadBufferBytes) \
|
|
|
|
|
M(UncompressedCacheHits) \
|
|
|
|
|
M(UncompressedCacheMisses) \
|
|
|
|
|
M(UncompressedCacheWeightLost) \
|
|
|
|
|
M(IOBufferAllocs) \
|
|
|
|
|
M(IOBufferAllocBytes) \
|
|
|
|
|
M(ArenaAllocChunks) \
|
|
|
|
|
M(ArenaAllocBytes) \
|
|
|
|
|
M(FunctionExecute) \
|
|
|
|
|
M(MarkCacheHits) \
|
|
|
|
|
M(MarkCacheMisses) \
|
2015-04-16 12:06:05 +00:00
|
|
|
|
M(CreatedReadBufferOrdinary) \
|
|
|
|
|
M(CreatedReadBufferAIO) \
|
|
|
|
|
M(CreatedWriteBufferOrdinary) \
|
|
|
|
|
M(CreatedWriteBufferAIO) \
|
2014-04-08 17:45:21 +00:00
|
|
|
|
\
|
2014-09-13 18:34:08 +00:00
|
|
|
|
M(ReplicatedPartFetches) \
|
|
|
|
|
M(ReplicatedPartFailedFetches) \
|
|
|
|
|
M(ObsoleteReplicatedParts) \
|
|
|
|
|
M(ReplicatedPartMerges) \
|
|
|
|
|
M(ReplicatedPartFetchesOfMerged) \
|
|
|
|
|
M(ReplicatedPartChecks) \
|
|
|
|
|
M(ReplicatedPartChecksFailed) \
|
2014-10-18 17:37:55 +00:00
|
|
|
|
M(ReplicatedDataLoss) \
|
2014-01-03 08:20:13 +00:00
|
|
|
|
\
|
2014-09-13 18:34:08 +00:00
|
|
|
|
M(DelayedInserts) \
|
|
|
|
|
M(RejectedInserts) \
|
|
|
|
|
M(DelayedInsertsMilliseconds) \
|
2015-06-05 17:34:57 +00:00
|
|
|
|
M(SynchronousMergeOnInsert) \
|
2014-09-11 20:34:41 +00:00
|
|
|
|
\
|
2014-09-13 18:34:08 +00:00
|
|
|
|
M(ZooKeeperInit) \
|
|
|
|
|
M(ZooKeeperTransactions) \
|
|
|
|
|
M(ZooKeeperGetChildren) \
|
|
|
|
|
M(ZooKeeperCreate) \
|
|
|
|
|
M(ZooKeeperRemove) \
|
|
|
|
|
M(ZooKeeperExists) \
|
|
|
|
|
M(ZooKeeperGet) \
|
|
|
|
|
M(ZooKeeperSet) \
|
|
|
|
|
M(ZooKeeperMulti) \
|
|
|
|
|
M(ZooKeeperExceptions) \
|
|
|
|
|
\
|
2014-11-23 04:01:36 +00:00
|
|
|
|
M(DistributedConnectionFailTry) \
|
|
|
|
|
M(DistributedConnectionFailAtAll) \
|
|
|
|
|
\
|
2015-05-05 15:50:20 +00:00
|
|
|
|
M(CompileAttempt) \
|
|
|
|
|
M(CompileSuccess) \
|
|
|
|
|
\
|
2015-12-03 21:23:21 +00:00
|
|
|
|
M(ExternalSortWritePart) \
|
|
|
|
|
M(ExternalSortMerge) \
|
|
|
|
|
M(ExternalAggregationWritePart) \
|
|
|
|
|
M(ExternalAggregationMerge) \
|
|
|
|
|
M(ExternalAggregationCompressedBytes) \
|
|
|
|
|
M(ExternalAggregationUncompressedBytes) \
|
|
|
|
|
\
|
2014-09-13 18:34:08 +00:00
|
|
|
|
M(END)
|
2014-01-03 08:20:13 +00:00
|
|
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
|
{
|
|
|
|
|
/// Виды событий.
|
|
|
|
|
enum Event
|
|
|
|
|
{
|
2014-09-13 18:34:08 +00:00
|
|
|
|
#define M(NAME) NAME,
|
2014-01-03 08:20:13 +00:00
|
|
|
|
APPLY_FOR_EVENTS(M)
|
|
|
|
|
#undef M
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Получить текстовое описание события по его enum-у.
|
|
|
|
|
inline const char * getDescription(Event event)
|
|
|
|
|
{
|
|
|
|
|
static const char * descriptions[] =
|
|
|
|
|
{
|
2014-09-13 18:34:08 +00:00
|
|
|
|
#define M(NAME) #NAME,
|
2014-01-03 08:20:13 +00:00
|
|
|
|
APPLY_FOR_EVENTS(M)
|
|
|
|
|
#undef M
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return descriptions[event];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Счётчики - сколько раз каждое из событий произошло.
|
2014-01-04 11:43:16 +00:00
|
|
|
|
extern size_t counters[END];
|
2014-01-03 08:20:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Увеличить счётчик события. Потокобезопасно.
|
|
|
|
|
inline void increment(Event event, size_t amount = 1)
|
|
|
|
|
{
|
|
|
|
|
__sync_fetch_and_add(&counters[event], amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef APPLY_FOR_EVENTS
|