Add a wait stacks achievement.

This commit is contained in:
Bartosz Taudul
2026-11-04 01:29:15 +01:00
parent 458faecb34
commit f86bdf7bb1
4 changed files with 27 additions and 1 deletions
+1
View File
@@ -248,6 +248,7 @@ Embed(PROFILER_FILES TextSamplingIntro src/achievements/SamplingIntro.md TEXT)
Embed(PROFILER_FILES TextSamplingStats src/achievements/SamplingStats.md TEXT)
Embed(PROFILER_FILES TextSaveTrace src/achievements/SaveTrace.md TEXT)
Embed(PROFILER_FILES TextSurviveCrash src/achievements/SurviveCrash.md TEXT)
Embed(PROFILER_FILES TextWaitStacks src/achievements/WaitStacks.md TEXT)
Embed(PROFILER_FILES TextZoneCallstacks src/achievements/ZoneCallstacks.md TEXT)
Embed(PROFILER_FILES TextSections src/achievements/Sections.md TEXT)
+14
View File
@@ -0,0 +1,14 @@
# Read wait stacks
Context switch sampling also captures a thread's call stack as it leaves the CPU. [Wait stacks](#waitstacks) collect those stacks over the whole capture, rank the wait sites by frequency, and show what the threads were doing when they waited.
Open * Wait stacks* in the * Tools* menu.
1. The list shows one wait stack at a time, most frequent first.
2. The bottom-up and top-down trees group the stacks by call path (see [Stacks windows](#stackwindows)).
A lot of it is noise: the scheduler takes threads off cores for its own reasons, and a stack ending in a sleep, a lock, or I/O is a wait your program chose. The stacks worth attention are the waits you did not expect.
Wait stacks are captured at scheduling events, so the counts show how often each wait happened.
Try it out: open the window and read the top stack of your capture.
+11 -1
View File
@@ -46,6 +46,7 @@
#include "data/TextSections.hpp"
#include "data/TextSaveTrace.hpp"
#include "data/TextSurviveCrash.hpp"
#include "data/TextWaitStacks.hpp"
#include "data/TextZoneCallstacks.hpp"
namespace tracy::data
@@ -80,10 +81,19 @@ AchievementItem ai_entryStacks = {
.text = Unpack( TextEntryStacks )
};
AchievementItem ai_waitStacks = {
.id = "waitStacks",
.name = "Read wait stacks",
.text = Unpack( TextWaitStacks )
};
AchievementItem* ac_contextSwitchesItems[] = { &ai_waitStacks, nullptr };
AchievementItem ai_contextSwitches = {
.id = "contextSwitches",
.name = "See the whole machine",
.text = Unpack( TextContextSwitches )
.text = Unpack( TextContextSwitches ),
.items = ac_contextSwitchesItems
};
AchievementItem ai_cpuData = {
+1
View File
@@ -1007,6 +1007,7 @@ bool View::DrawImpl()
const auto cscnt = m_worker.GetContextSwitchSampleCount();
if( ButtonDisablable( ICON_FA_HOURGLASS_HALF " Wait stacks", cscnt == 0 ) )
{
if( s_config.achievements ) Achieve( "waitStacks" );
m_showWaitStacks = true;
}
if( ButtonDisablable( ICON_FA_IMAGES " Frame statistics", !m_worker.AreFramesUsed() ) )