code cleanup

This commit is contained in:
Dmitry Novik 2021-10-11 16:55:08 +03:00
parent 7c3192735a
commit bfdd34c13d
3 changed files with 6 additions and 35 deletions

View File

@ -667,18 +667,19 @@ void ClientBase::onEndOfStream()
void ClientBase::onProfileEvents(Block & block)
{
if (block.rows() == 0)
const auto rows = block.rows();
if (rows == 0)
return;
const auto & array_thread_id = typeid_cast<const ColumnUInt64 &>(*block.getByName("thread_id").column).getData();
const auto & names = typeid_cast<const ColumnString &>(*block.getByName("name").column);
const auto & host_names = typeid_cast<const ColumnString &>(*block.getByName("host_name").column);
const auto & array_values = typeid_cast<const ColumnUInt64 &>(*block.getByName("value").column).getData();
auto const * user_time_name = ProfileEvents::getName(ProfileEvents::UserTimeMicroseconds);
auto const * system_time_name = ProfileEvents::getName(ProfileEvents::SystemTimeMicroseconds);
const auto * user_time_name = ProfileEvents::getName(ProfileEvents::UserTimeMicroseconds);
const auto * system_time_name = ProfileEvents::getName(ProfileEvents::SystemTimeMicroseconds);
HostToThreadTimesMap thread_times;
for (size_t i = 0; i < block.rows(); ++i)
for (size_t i = 0; i < rows; ++i)
{
auto thread_id = array_thread_id[i];
auto host_name = host_names.getDataAt(i).toString();

View File

@ -598,7 +598,6 @@ namespace
void addExtremesToResult(const Block & extremes);
void addProfileInfoToResult(const BlockStreamProfileInfo & info);
void addLogsToResult();
void addProfileEventsToResult();
void sendResult();
void throwIfFailedToSendResult();
void sendException(const Exception & exception);
@ -624,7 +623,6 @@ namespace
BlockIO io;
Progress progress;
InternalTextLogsQueuePtr logs_queue;
InternalProfileEventsQueuePtr profile_queue;
GRPCQueryInfo query_info; /// We reuse the same messages multiple times.
GRPCResult result;
@ -776,8 +774,6 @@ namespace
CurrentThread::attachInternalTextLogsQueue(logs_queue, client_logs_level);
CurrentThread::setFatalErrorCallback([this]{ onFatalError(); });
}
profile_queue = std::make_shared<InternalProfileEventsQueue>(std::numeric_limits<int>::max());
CurrentThread::attachInternalProfileEventsQueue(profile_queue);
/// Set the current database if specified.
if (!query_info.database().empty())
@ -1129,7 +1125,6 @@ namespace
if (after_send_progress.elapsedMicroseconds() >= interactive_delay)
{
addProgressToResult();
addProfileEventsToResult();
after_send_progress.restart();
}
@ -1181,7 +1176,6 @@ namespace
finalize = true;
io.onFinish();
addProgressToResult();
addProfileEventsToResult();
query_scope->logPeakMemoryUsage();
addLogsToResult();
sendResult();
@ -1445,11 +1439,6 @@ namespace
}
}
void Call::addProfileEventsToResult()
{
}
void Call::sendResult()
{
/// gRPC doesn't allow to write anything to a finished responder.

View File

@ -844,7 +844,6 @@ namespace
{
UInt64 thread_id;
ProfileEvents::Counters counters;
CurrentMetrics::Metric metric;
Int64 memory_usage;
time_t current_time;
};
@ -899,22 +898,6 @@ namespace
columns[i++]->insertData(MemoryTracker::USAGE_EVENT_NAME, strlen(MemoryTracker::USAGE_EVENT_NAME));
columns[i++]->insert(snapshot.memory_usage);
}
if (snapshot.metric != CurrentMetrics::end())
{
time_t current_time = time(nullptr);
size_t i = 0;
columns[i++]->insertData(host_name.data(), host_name.size());
columns[i++]->insert(UInt64(current_time));
columns[i++]->insert(UInt64{snapshot.thread_id});
columns[i++]->insert(ProfileEventTypes::GAUGE);
auto const * metric_name = CurrentMetrics::getName(snapshot.metric);
columns[i++]->insertData(metric_name, strlen(metric_name));
auto metric_value = CurrentMetrics::get(snapshot.metric);
columns[i++]->insert(metric_value);
}
}
}
@ -953,6 +936,7 @@ void TCPHandler::sendProfileEvents()
ProfileEventsSnapshot group_snapshot;
{
std::lock_guard guard(thread_group->mutex);
snapshots.reserve(thread_group->threads.size());
for (auto * thread : thread_group->threads)
{
auto const thread_id = thread->thread_id;
@ -960,12 +944,10 @@ void TCPHandler::sendProfileEvents()
continue;
auto current_time = time(nullptr);
auto counters = thread->performance_counters.getPartiallyAtomicSnapshot();
auto metric = thread->memory_tracker.getMetric();
auto memory_usage = thread->memory_tracker.get();
snapshots.push_back(ProfileEventsSnapshot{
thread_id,
std::move(counters),
metric,
memory_usage,
current_time
});
@ -973,7 +955,6 @@ void TCPHandler::sendProfileEvents()
group_snapshot.thread_id = 0;
group_snapshot.current_time = time(nullptr);
group_snapshot.metric = thread_group->memory_tracker.getMetric();
group_snapshot.memory_usage = thread_group->memory_tracker.get();
group_snapshot.counters = thread_group->performance_counters.getPartiallyAtomicSnapshot();
}