← Back to Pull requests

[interop] Cache types resolved through the typeof trampoline #117

Open
unknown opened this pull request with 239 lines diff across 2 files
View on GitHub
unknown unknown commented on Sep 27, 2026 09:27 UTC
Author

GetType() resolves names that Cpp::GetType() cannot handle by declaring using <unique id> = __typeof__(<name>); in the interpreter. Without a cache, every call parses and compiles code and adds one more alias to the AST, growing the interpreter state unboundedly for repeated names.

Memoize the resolved types by name. A name that fails to resolve may succeed once more declarations are available, so failures are retried.

Upstream motivation: in ROOT, reading a TTree array branch creates the converter for the branch's element pointer type (e.g. "Double_t") on every access, so an event loop went through the trampoline for every entry. The original reproducer:

import array
import time
import ROOT
n = array.array("i", [3])
e = array.array("d", [1.0, 2.0, 3.0])
tree = ROOT.TTree("tree", "")
tree.Branch("n", n, "n/I")
tree.Branch("e", e, "e[n]/D")
for _ in range(10000):
tree.Fill()
start = time.perf_counter()
for event in tree:
event.e # array branch: the converter for "Double_t
" is created on each access
print(f"loop over 10000 entries reading an array branch: {time.perf_counter() - start:.2f} s")

This takes 0.11 s instead of 1.66 s with this change.

On performance in cppjit proper, the honest result of validating this is that no equivalent hot path exists here: with an instrumented build, the full test suite (559 tests) and targeted scenarios (STL container template instantiation, low-level views, callbacks through std::function, operator dispatch, exception translation) produce exactly one trampoline invocation per process, the one-time resolution of std::exception. Spellings like "double*" are resolved by Cpp::GetType directly. So there is no cppjit-side number to quote; the cache prevents AST alias growth for consumers that do drive this path repeatedly, at the cost of one map lookup per call.

Diff: 239 lines (+179 / -60) across 2 files Reviewer: vgvassilev Review duration: 9653m
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 239 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.328
Real PR Conversation Timeline
1 comments
"Review active on #117"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 37.2% (MEDIUM) · Higher = larger blast radius
37.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 46.7% · Lower = rushed or shallow review
46.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 19.9% · Safe to merge
19.9%