tqchen opened a new pull request, #744:
URL: https://github.com/apache/tvm-ffi/pull/744

   `TryLink` inlines into the per-node dispatch function, so two error 
constructions that only the matched path can reach put their string and `Error` 
construction into a stack frame every node pays for.
   
   This follows `BadStructuralMutateHookError`, which is already 
`TVM_FFI_COLD_CODE static` for exactly this reason — its doc comment says 
*"Inlined, its three string literals and Error construction land in the 
traversal's hot path for no reason."* These were the two sites it missed.
   
   No semantic change: both checks still fire identically, only the location of 
their error construction moves.
   
   ## Codegen
   
   Per-node dispatch function:
   
   | | frame | instructions |
   |---|---:|---:|
   | before | 216 B | 358 |
   | after | **120 B** | **318** |
   
   Both helpers land in `.text.unlikely.*`. `TVM_FFI_NO_INLINE` was tried and 
is redundant — `COLD` alone gives byte-identical codegen, so the annotation 
matches the existing precedent.
   
   ## Measurement
   
   Standalone harness mirroring the TIR node shapes, full `-O3` for library and 
benchmark, pinned, baseline and candidate libraries built identically, binaries 
run **interleaved over 11 pairs**, medians in ns/node:
   
   | arm | before | after | |
   |---|---:|---:|---:|
   | no link matches | 14.12 | 13.80 | −2.3% |
   | link matches, no rebuild | 21.37 | 20.79 | −2.7% |
   | link matches, node replaced | 22.79 | 21.22 | **−6.9%** |
   
   The first row is the one that generalizes: it is what a node runs when no 
link matches, which is most nodes on a real tree.
   
   ## Notes
   
   The descent `TypeError` is not removable — without it, dereferencing a 
`nullopt` `descended_sub` is undefined behavior. Only its construction moves.
   
   Two other candidates for this same path were measured and dropped: a 
`TVM_FFI_UNSAFE_ASSUME` that the untouched `Expected<Any>` holds None produced 
byte-identical assembly, and making the var-remap map allocation lazy was worth 
~0.15 ns/node.
   
   479/479 C++ tests pass under gcc and clang++-17.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to