diff --git a/common/generic_dir.hh b/common/generic_dir.hh index ab71c55..9f3a062 100644 --- a/common/generic_dir.hh +++ b/common/generic_dir.hh @@ -9,6 +9,8 @@ #include #include +#include + #include "nf7.hh" #include "common/dir.hh" @@ -122,6 +124,9 @@ class GenericDir : public nf7::FileBase::Feature, public nf7::Dir { } void UpdateChildren(bool early) noexcept { for (auto& p : items_) { + ZoneScopedN("update child"); + ZoneText(p.first.data(), p.first.size()); + auto& f = *p.second; auto* ditem = f.interface(); diff --git a/file/node_network.cc b/file/node_network.cc index f473aaa..5f7e9e5 100644 --- a/file/node_network.cc +++ b/file/node_network.cc @@ -16,6 +16,8 @@ #include +#include + #include #include @@ -306,6 +308,9 @@ class Network::Item final { void Detach() noexcept; void Update() noexcept { + ZoneScoped; + ZoneValue(id_); + assert(owner_); ImGui::PushID(file_.get()); file_->Update(); @@ -386,6 +391,8 @@ class Network::Lambda : public Node::Lambda, // send input from outer to input handlers if (in.sender == parent) { + ZoneScopedN("return value"); + for (auto& item : f_->items_) { if (item->iflags() & InternalNode::kInputHandler) { try { @@ -401,6 +408,8 @@ class Network::Lambda : public Node::Lambda, // send an output from children as input to children try { + ZoneScopedN("transmit value"); + auto itr = idmap_.find(in.sender.get()); if (itr == idmap_.end()) { throw nf7::Exception {"called by unknown lambda"}; diff --git a/file/system_dir.cc b/file/system_dir.cc index b87f031..68ad693 100644 --- a/file/system_dir.cc +++ b/file/system_dir.cc @@ -12,6 +12,8 @@ #include #include +#include + #include "nf7.hh" #include "common/config.hh" diff --git a/main.cc b/main.cc index fe491d2..30ff74a 100644 --- a/main.cc +++ b/main.cc @@ -126,6 +126,7 @@ void WorkerThread() noexcept { FrameMarkEnd(kThreadId); } + TracyMessageL("SyncWorker exitting"); } void AsyncThread() noexcept { @@ -160,10 +161,11 @@ void AsyncThread() noexcept { FrameMarkEnd(kThreadId); } + TracyMessageL("AsyncWorker exitting"); } void GLThread(GLFWwindow* window) noexcept { - [[maybe_unused]] const char kThreadId[] = "AsyncWorker"; + [[maybe_unused]] const char kThreadId[] = "GLWorker"; tracy::SetThreadName("GLWorker"); std::unique_lock k {cycle_mtx_}; @@ -210,6 +212,7 @@ void GLThread(GLFWwindow* window) noexcept { FrameMarkEnd(kThreadId); } + TracyMessageL("GLWorker exitting"); } @@ -487,16 +490,15 @@ int main(int, char**) { // load GUI font if (std::filesystem::exists(kFontPath)) { + ZoneScopedN("load GUI font"); io.Fonts->AddFontFromFileTTF( kFontPath, 16.f, nullptr, io.Fonts->GetGlyphRangesJapanese()); } // main loop - [[maybe_unused]] const char kThreadId[] = "GUI"; ::Env env; glfwShowWindow(window); while (!glfwWindowShouldClose(window) && !env.exitRequested()) { - FrameMarkStart(kThreadId); nf7::Stopwatch sw; { @@ -553,7 +555,7 @@ int main(int, char**) { } std::this_thread::sleep_for(kFrameDur - sw.dur()); - FrameMarkEnd(kThreadId); + FrameMark; } // sync with worker thread and tear down filesystem @@ -563,8 +565,12 @@ int main(int, char**) { cycle_cv_.notify_all(); cycle_cv_.wait(k, []() { return cycle_ == kUpdate; }); } - assert(cycle_ == kUpdate); - env.TearDownRoot(); + + { + ZoneScopedN("teardown root"); + assert(cycle_ == kUpdate); + env.TearDownRoot(); + } // notify other threads that the destruction is done { @@ -573,16 +579,21 @@ int main(int, char**) { cycle_cv_.notify_all(); } - TracyMessageL("waiting for all tasks"); - for (;;) { - std::unique_lock sk {task_mtx_}; - if (!mainq_.size() && !subq_.size() && !asyncq_.size() && !glq_.size()) { - break; + { + ZoneScopedN("wait for all tasks"); + for (;;) { + { + ZoneScopedN("check remained tasks"); + std::unique_lock sk {task_mtx_}; + if (!mainq_.size() && !subq_.size() && !asyncq_.size() && !glq_.size()) { + break; + } + } + std::this_thread::sleep_for(30ms); } - std::this_thread::sleep_for(30ms); } - TracyMessageL("exitting SyncWorker and AsyncWorker"); + // request SyncWorker and AsyncWorker to exit { alive_ = false; cycle_ = kSyncUpdate; @@ -591,14 +602,16 @@ int main(int, char**) { } for (auto& th : th_async) th.join(); th_worker.join(); + TracyMessageL("SyncWorker and AsyncWorker exited"); - TracyMessageL("exitting GLWorker"); + // wake up GLWorker to exit { cycle_ = kSyncDraw; std::unique_lock k {cycle_mtx_}; cycle_cv_.notify_all(); } th_gl.join(); + TracyMessageL("GLWorker exited"); { ZoneScopedN("tear down everything");