mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:05:53 +01:00
[PR #55] tools: one cached work_root() per shader instead of nine realpath() calls (-14% fixed cost, byte-identical) #106
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#106
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/55
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/9777📝 Commits (3)
e606b54tools: one cached work_root() instead of nine repeated realpath() calls per shadere535c92report_paths: resolve a relative work_root every time, never from the cacheec340d9tests: compare work_root with the resolved temporary folder, as the function returns it📊 Changes
4 files changed (+65 additions, -10 deletions)
View changed files
📝
tests/test_report_paths.py(+28 -0)📝
tools/rdna2spirv.py(+6 -6)📝
tools/report_paths.py(+25 -0)📝
tools/shader_meta.py(+6 -4)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Every shader of the build pays 0.8 ms of path resolution that nothing needs. A build translates 26,503 shaders; this takes ~14% off the fixed cost of each one, with byte-identical output.
Nine places derive a shader's work folder with the same expression — five in
rdna2spirv.py, four inshader_meta.py:They run for
index.json(which gives the stage), the.dxbcinput signature and thefssmheader, so the same directory is resolved up to sixteen times per shader, andos.path.realpathis a_getfinalpathnamecall on Windows (~40 µs measured).What changes
report_paths.work_root()— that module already owns the path rules — resolves the folder once per path and keeps it, with a capped table (1<<14) and a clear at the cap, so a process that walks a whole corpus cannot grow it. A relative path is resolved every time and never cached: the same spelling names a different folder after achdir(found in review by@senyurah, fixed, with a regression test).Measured
scripts/bench_translate.py --compare(#7056), which alternates the twotools/trees in the same round, drops a warm-up round and keeps the best of 3 per side; 5 rounds, Windows 11, Python 3.12.4:s_nop, 2,004The same-tree control of that harness reads 1.01x / 1.00x / 0.99x, so 0.86x is outside its noise.
Correct because
157189dcc0158f00…before and after.scripts/run_semantic_tests.py tests/semantic: 5,821 tests, the same single pre-existing red file asmain(test_float_nan_fract).main.tests/test_report_paths.py: 24 tests, five new ones for this (including thechdircase).cc
@ItsNotRexed@KoertLichtendonkChecklist
docs/design.md. (Not applicable: no rule changes; the emitted SPIR-V is byte-identical.)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.