d3d12: say where a slow pipeline came from, and whether its journal was written

The slow-pipeline line reported 	ook N s to build for a timer that starts before the journal file is read
and before the shared cache is asked, so it named a compile for what could be a cache lookup. Chasing a compile
cost from it is chasing the wrong number: a run with 16 such lines had compiled exactly one pipeline.

The line now names the source (a compile, the shared cache, or the pipeline's own journal file) and carries the
hit the journal reported, whether its cache was seeded from a file, and whether the file was written afterwards.
That is what turned three contradictory readings of the same log into one, on an RTX 4090 with a warm journal:
23 slow lines, all hit 0, seeded 0, written 1 - first-sight pipelines, each compiled once and journaled.
This commit is contained in:
fiestorra
2026-11-29 14:07:41 +01:00
committed by t
parent b17b22d331
commit 7acf84d38f

View File

@ -17727,6 +17727,7 @@ ComputeBuild build_compute_pipeline(DeviceState& device, const leonida::ShaderEn
auto& compiling = leonida::driver_compile;
VkResult created = VK_ERROR_UNKNOWN;
bool from_shared = false, probe_compiled = false;
int hit_reported = -1; // what the journal sees as its hit, printed below to explain a missing write
ULONGLONG probe_ms = 0, driver_ms = 0;
{
// Every driver call of the build (shader module, journal cache, pipeline) in one turn through the compile
@ -17773,7 +17774,8 @@ ComputeBuild build_compute_pipeline(DeviceState& device, const leonida::ShaderEn
}
compiling.name.store(nullptr, std::memory_order_release);
vk.vkDestroyShaderModule(dev, module, nullptr); // Vulkan lets a module go once the pipeline exists
journal.finish(!from_shared && created == VK_SUCCESS && built, trace.hit(), driver_ms);
hit_reported = trace.hit(); // what finish() sees; decides whether the file is written
journal.finish(!from_shared && created == VK_SUCCESS && built, hit_reported, driver_ms);
}
std::vector<std::uint32_t>().swap(words);
profile.finish(int(created));
@ -17793,9 +17795,15 @@ ComputeBuild build_compute_pipeline(DeviceState& device, const leonida::ShaderEn
out.journaled = journal.written();
out.ms = GetTickCount64() - started;
if (created == VK_SUCCESS && built && out.ms >= 2000)
std::fprintf(stderr, "[rt] d3d12: compute pipeline %s took %.1f s to build (%zu B SPIR-V)\n",
entry->name.c_str(), double(out.ms) / 1000.0, bytes);
return out;
// The timer starts before the journal file is read and before the shared cache is asked, so this
// line reports the whole call. Name where the pipeline came from: a compile, the shared cache or
// its own journal file, which is what a compile cost has to be read from.
std::fprintf(stderr,
"[rt] d3d12: compute pipeline %s took %.1f s to obtain from %s (%zu B SPIR-V; hit %d,"
" seeded %d, written %d)\n",
entry->name.c_str(), double(out.ms) / 1000.0,
out.journal_hit ? "its journal file" : out.from_shared ? "the shared cache" : "a compile",
bytes, hit_reported, int(journal.seeded), int(out.journaled));
}
class PipelineState final