summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-30 18:34:37 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-06 11:50:46 -0600
commit8e21fcfc3b332e749135e4081dacb5556b30f5be (patch)
treefcf9a894fc1e2047f1b736495bcf247242e22193
parent3adb478bb5257ab48f366f58f2a2ce3ae1115b97 (diff)
measurestack: Add `dbg_(no)cache` toggles
-rw-r--r--build-aux/measurestack/analyze.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/build-aux/measurestack/analyze.py b/build-aux/measurestack/analyze.py
index 3601707..93bf885 100644
--- a/build-aux/measurestack/analyze.py
+++ b/build-aux/measurestack/analyze.py
@@ -10,10 +10,14 @@ import typing
from . import vcg
+# Whether to print "//dbg-cache:" on cache writes
+dbg_cache = False
# Whether to print the graph in a /* comment */ before processing it
dbg_dumpgraph = False
# Whether to print "//dbg-nstatic:" lines that trace nstatic() execution
dbg_nstatic = False
+# Whether to disable nstatic() caching (but does NOT disable any cache-related debug logging)
+dbg_nocache = False
# Whether to sort things for consistently-ordered execution, or shuffle things to detect bugs
dbg_sort: typing.Literal["unsorted", "sorted", "shuffled"] = "unsorted"
@@ -512,7 +516,11 @@ def analyze(
continue
# 3. Call
- if skip_nchain == 0 and call_qname in _nstatic_cache:
+ if (
+ (not dbg_nocache)
+ and skip_nchain == 0
+ and call_qname in _nstatic_cache
+ ):
call_nstatic = _nstatic_cache[call_qname]
if dbg_nstatic:
putdbg(f"{call_qname}\ttotal={call_nstatic} (cache-read)")
@@ -524,7 +532,13 @@ def analyze(
if skip_nchain == 0 and call_nchain == 0:
if dbg_nstatic:
putdbg(f"{call_qname}\ttotal={call_nstatic} (cache-write)")
- _nstatic_cache[call_qname] = call_nstatic
+ if call_qname not in _nstatic_cache:
+ if dbg_cache:
+ print(f"//dbg-cache: {call_qname} = {call_nstatic}")
+ _nstatic_cache[call_qname] = call_nstatic
+ else:
+ assert dbg_nocache
+ assert _nstatic_cache[call_qname] == call_nstatic
elif dbg_nstatic:
putdbg(f"{call_qname}\ttotal={call_nstatic} (do-not-cache)")
chain.pop()