You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
2.0.40: on the CPU, every take of a shared node is a call (#1978), +10% instructions on a list-heavy program #2081
#1978 fixed the M1 Metal miscompile by moving the shared-node half of ctr_take into span_fade and making span_fadeFAR. The PR body says "Host and CUDA keep OUTLINE as before, with the last-holder free now inside it", but the C that 2.0.40 emits for the host has FAR u64 span_fade, so on the CPU the change is more than a move:
2.0.39:ctr_take checks the count inline and frees a last-held node in place. Only a node that really is shared calls span_fade, which is OUTLINE (cold, preserve_most).
2.0.40: every take of a node with the RFC bit calls span_fade, a plain noinline with the normal calling convention. The count check runs inside it.
I added a counter to the C. The program calls span_fade 1.21 G times on 2.0.40, against 39.5 M times on 2.0.39. 1.15 G of those calls are takes of a last-held node, which 2.0.39 handles inline.
With ctr_take and span_fade put back as in 2.0.39 in comp.ts at v2.0.40 (only that text, built with bun bend2/main.ts), the program runs 173.6 G instructions. That is 10.6% fewer than the release and 2.3% under 2.0.39.
Keeping 2.0.40's shape but marking span_fadeOUTLINE makes it worse: 209.1 G instructions. preserve_most is then paid on every one of those 1.2 G calls. On the host, the last-holder check has to stay inline.
My suggestion is to keep 2.0.39's ctr_take and span_fade outside Metal, and #1978's shape under __METAL_VERSION__ only. I can't test the M1 side. The CUDA build goes through the same FAR and may want the same split, but I haven't measured it.
Activity