chore: add task debugging log

This commit is contained in:
Paul Pan 2023-03-23 15:28:40 +08:00
parent 8b404149e7
commit 8c9c3d0221
5 changed files with 40 additions and 3 deletions

View File

@ -47,7 +47,7 @@ endif ()
# common
set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(BASE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BASE_LIBS sentry::sentry spdlog::spdlog nlohmann_json::nlohmann_json)
set(BASE_LIBS sentry::sentry spdlog::spdlog nlohmann_json::nlohmann_json magic_enum::magic_enum)
if (NOT CE_NO_TRACE)
list(APPEND BASE_LIBS perfetto)
endif ()

View File

@ -144,6 +144,20 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(json)
##############
# Magic Enum #
##############
message(STATUS "Using FetchContent to download magic_enum")
FetchContent_Declare(
magic_enum
GIT_REPOSITORY https://github.com/Neargye/magic_enum
GIT_TAG v0.8.2
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(magic_enum)
##########
# Catch2 #
##########

View File

@ -42,6 +42,11 @@ void Offload::Scheduler::Start() {
}
}
static int count = 0;
if (++count % 30 == 0) {
rtState->PrintTasks();
}
std::this_thread::sleep_for(std::chrono::milliseconds(800));
}
}

View File

@ -1,6 +1,7 @@
#include <spdlog/spdlog.h>
#include <utility>
#include <magic_enum.hpp>
#include "RTState.h"
#include "offload/Context.h"
#include "utils/utils.h"
@ -131,7 +132,7 @@ uint32_t State::RTState::NewTask(TaskDesc task, bool toRemote) {
/* 分配到任务队列 */
if (pressure != SIZE_MAX) {
if (pressure > 0) spdlog::warn("RTState: no idle runner found, overrun! pressure={}", pressure);
if (pressure > 0) spdlog::warn("RTState: no idle runner found, overrun! min-pressure={}", pressure);
task->runner.thread_id = fallbackVictim;
@ -204,3 +205,19 @@ void State::RTState::UpdateHostInfo(const State::Host &host, const State::HostIn
wlock lk_host(host_mu);
hostInfos[host.name] = info;
}
void State::RTState::PrintTasks() {
rlock lk_task(task_mu);
mlock lk_runner(runner_mu);
spdlog::debug("┌──── RTState::PrintTasks");
spdlog::debug("│ total pending: {}", pendingCount);
for (auto &[hnd, tsk] : taskIndex) {
spdlog::debug("│ task {}@{}:", tsk->task.program, tsk->task.function_ptr);
spdlog::debug("│ local_handle: {}", tsk->local_handle);
spdlog::debug("│ host: {}", tsk->host.name);
spdlog::debug("│ runner: remote={}, remote_handle={}", tsk->runner.from_remote, tsk->runner.remote_handle);
spdlog::debug("│ state: {}", magic_enum::enum_name(tsk->state.load()));
}
spdlog::debug("└──── END");
}

View File

@ -20,6 +20,7 @@ class RTState {
/* Debugging */
void PrintTraces();
void PrintTasks();
uint32_t NewTaskBlock(const std::thread::id &id, std::shared_ptr<RuntimeTaskUnit> task);
/* Host Related */