Commit 0c99ac8
committed
JIT: stop watching types that churn their inline-cache invalidations
Workloads that frequently mutate a small set of types on a hot path
(PyTorch's autocast/no-grad/training-mode contexts are the canonical
example) trigger full inline-cache invalidation on every mutation.
Even when the inline cache is not actually missing for the lookups
that matter, the per-mutation watcher-notification chain dominates
execution time.
Track per-type invalidation count. Once a type has been invalidated
beyond a threshold (default 10), mark it volatile and stop registering
new IC watchers for it. Inline-cache lookups against volatile types
fall back to the slow path — correct, but no longer paying the
notification cost.
The change touches only the inline-cache layer; downstream cache
behaviour for non-volatile types is unchanged.
Empirical: this patch applied to upstream master HEAD reproduces the
pytorch_cm speedup on both architectures. PR-branch measurements at
reps=5: 1.35x x86_64 (170.89ms cinderx vs 230.22ms vanilla, +25.8%)
and 1.17x aarch64 (79.53ms cinderx vs 93.41ms vanilla, +14.9%). A
corroborating-prior forward-port ablation on a master substrate
~11 days older measured 1.13x x86_64 and 1.08x aarch64 at reps=5;
substrate-differences (bench mode and build-flag adjustments and
11 days of intervening master commits) account for the magnitude
variance, and the speedup direction and mechanism reproduce on both
architectures.1 parent 28a57df commit 0c99ac8
1 file changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
25 | 42 | | |
26 | 43 | | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
30 | 50 | | |
31 | 51 | | |
32 | 52 | | |
| |||
1601 | 1621 | | |
1602 | 1622 | | |
1603 | 1623 | | |
| 1624 | + | |
1604 | 1625 | | |
1605 | 1626 | | |
1606 | 1627 | | |
| |||
0 commit comments