Skip to content

Commit 16914da

Browse files
author
koshkovka
committed
refactor engine: remove most of LOG_TRACE() from engine/
This is to avoid the cost of a no-op `LOG_TRACE` on hot paths. commit_hash:c9b52bd7a6bdec6feb62e10a152dfc7a2a795c76
1 parent ec9e264 commit 16914da

8 files changed

Lines changed: 1 addition & 26 deletions

File tree

core/src/engine/ev/thread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ void Thread::UpdateTimersWatcher(struct ev_loop* loop, ev_timer*, int) noexcept
161161

162162
void Thread::UpdateLoopWatcherImpl() {
163163
while (AsyncPayloadBase* payload = func_queue_.TryPopBlocking()) {
164-
LOG_TRACE() << "Thread::UpdateLoopWatcherImpl(), " << compiler::GetTypeName(typeid(*payload));
165164
try {
166165
payload->PerformAndRelease();
167166
} catch (const std::exception& ex) {

core/src/engine/ev/watcher/async_watcher.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ void AsyncWatcher::OnEvent(struct ev_loop*, ev_async* async, int events) noexcep
3535

3636
void AsyncWatcher::Send() { ev_async_.Send(); }
3737

38-
void AsyncWatcher::CallCb() {
39-
LOG_TRACE() << "CallCb (1) watcher=" << this;
40-
41-
cb_();
42-
}
38+
void AsyncWatcher::CallCb() { cb_(); }
4339

4440
} // namespace engine::ev
4541

core/src/engine/ev/watcher/io_watcher.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,8 @@ void IoWatcher::CallWriteCb(std::error_code ec) {
104104
}
105105

106106
void IoWatcher::Cancel() {
107-
LOG_TRACE() << "IoWatcher::Cancel (1)";
108107
CancelSingle(watcher_write_, cb_write_);
109-
LOG_TRACE() << "IoWatcher::Cancel (2)";
110108
CancelSingle(watcher_read_, cb_read_);
111-
LOG_TRACE() << "IoWatcher::Cancel (3)";
112109
}
113110

114111
void IoWatcher::CancelSingle(Watcher<ev_io>& watcher, Callback& cb) {

core/src/engine/ev/watcher/timer_watcher.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ TimerWatcher::TimerWatcher(ThreadControl& thread_control)
1616
TimerWatcher::~TimerWatcher() { Cancel(); }
1717

1818
void TimerWatcher::SingleshotAsync(std::chrono::milliseconds timeout, Callback cb) {
19-
LOG_TRACE() << "TimerWatcher::SingleshotAsync";
2019
Cancel();
2120
{
2221
const std::lock_guard lock{mutex_};
@@ -41,7 +40,6 @@ void TimerWatcher::OnEventTimeout(struct ev_loop*, ev_timer* timer, int events)
4140
}
4241

4342
void TimerWatcher::CallTimeoutCb(std::error_code ec) {
44-
LOG_TRACE() << "TimerWatcher::CallTimeoutCb watcher=" << this;
4543
Callback cb;
4644
{
4745
const std::lock_guard lock{mutex_};
@@ -54,7 +52,6 @@ void TimerWatcher::CallTimeoutCb(std::error_code ec) {
5452
}
5553

5654
void TimerWatcher::Cancel() {
57-
LOG_TRACE() << "TimerWatcher::Cancel() (1) watcher=" << this;
5855
bool need_call_cb = false;
5956
{
6057
const std::lock_guard lock{mutex_};
@@ -63,12 +60,9 @@ void TimerWatcher::Cancel() {
6360
}
6461
}
6562
if (need_call_cb) {
66-
LOG_TRACE() << "TimerWatcher::Cancel() (2) watcher=" << this;
6763
ev_timer_.Stop();
68-
LOG_TRACE() << "TimerWatcher::Cancel() (2.1) watcher=" << this;
6964
CallTimeoutCb(std::make_error_code(std::errc::operation_canceled));
7065
}
71-
LOG_TRACE() << "TimerWatcher::Cancel() (3) watcher=" << this;
7266
}
7367

7468
} // namespace engine::ev

core/src/engine/impl/wait_list_light.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ namespace {
3333
Awaiter* const kSignaled = reinterpret_cast<Awaiter*>(1);
3434

3535
void DoNotify(AwaiterWithContext awaiter) {
36-
LOG_TRACE() << "NotifyOne awaiter=" << fmt::to_string(awaiter) << " use_count=" << awaiter.awaiter->UseCount();
3736
impl::Notify(boost::intrusive_ptr<Awaiter>{awaiter.awaiter, /*add_ref=*/false}, awaiter.context);
3837
}
3938

@@ -54,7 +53,6 @@ void WaitListLight::GetSignalOrAppend(boost::intrusive_ptr<Awaiter>& awaiter, st
5453
UASSERT(awaiter);
5554

5655
const AwaiterWithContext new_awaiter{awaiter.get(), context};
57-
LOG_TRACE() << "Append awaiter=" << fmt::to_string(new_awaiter) << " use_count=" << awaiter->UseCount();
5856

5957
AwaiterWithContext expected{};
6058
// seq_cst is important for the "Append-Check-Wakeup" sequence.
@@ -122,7 +120,6 @@ void WaitListLight::Remove(Awaiter& awaiter, std::uintptr_t context) noexcept {
122120
return;
123121
}
124122

125-
LOG_TRACE() << "Remove awaiter=" << fmt::to_string(expected) << " use_count=" << awaiter.UseCount();
126123
intrusive_ptr_release(&awaiter);
127124
}
128125

core/src/engine/single_consumer_event.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,15 @@ bool SingleConsumerEvent::WaitForEventUntil(Deadline deadline) {
4545
}
4646

4747
impl::TaskContext& current = current_task::GetCurrentTaskContext();
48-
LOG_TRACE() << "WaitForEventUntil()";
4948
EventWaitStrategy wait_manager{*this, current};
5049

5150
while (true) {
5251
if (GetIsSignaled()) {
53-
LOG_TRACE() << "success";
5452
return true;
5553
}
5654

57-
LOG_TRACE() << "iteration()";
58-
5955
const auto wakeup_source = current.Sleep(wait_manager, deadline);
6056
if (!impl::HasWaitSucceeded(wakeup_source)) {
61-
LOG_TRACE() << "failure";
6257
return false;
6358
}
6459
}

core/src/engine/task/context_timer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ void ContextTimer::Impl::DoArmTimerInEvThread() {
135135
using LibEvDuration = std::chrono::duration<double>;
136136
const auto time_left = std::chrono::duration_cast<LibEvDuration>(params_.deadline.TimeLeft()).count();
137137

138-
LOG_TRACE() << "time_left=" << time_left;
139138
if (time_left <= 0.0) {
140139
// Optimization for small deadlines or high load
141140
DoOnTimer();

core/src/engine/task/task_processor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ void TaskProcessor::CheckWaitTime(impl::TaskContext& context) {
419419
const auto wait_timepoint = context.GetQueueWaitTimepoint();
420420
if (wait_timepoint != std::chrono::steady_clock::time_point()) {
421421
const auto wait_time = std::chrono::steady_clock::now() - wait_timepoint;
422-
const auto wait_time_us = std::chrono::duration_cast<std::chrono::microseconds>(wait_time);
423-
LOG_TRACE() << "queue wait time = " << wait_time_us.count() << "us";
424422

425423
SetTaskQueueWaitTimeOverloaded(max_wait_time.count() && wait_time >= max_wait_time);
426424

0 commit comments

Comments
 (0)