def message

bend-lint-rules@0.2.0.0 · performance/deep_call_in_fork.bend:167

import bend-lint-rules@0.2.0.0/performance/deep_call_in_fork.bend as DeepCallInFork
import Base

167def message(+callee: String, loop: String) -> String:
168  callee
169    ++ " calls itself outside a tail position, so Bend gives each of its calls a frame, and "
170    ++ loop
171    ++ " calls it in a fork (a value of its parallel let, or of a let just before it). CPU: measured 4% to 8% faster for a raytracer after the fix; in a benchmark, such a call at each fork cut a 10x speedup to 1.9x. GPU: such a recursion in a `!` made a draw 2.3x slower (\"bend guide shaders\"). JS: not measured. Confidence: medium, as the cost grows with the depth of the recursion. Make "
172    ++ callee
173    ++ " tail-recursive with an accumulator, compute its value with native operations (such as U32.shln), or compute it once and pass it down as a parameter. If its input is short, expect this finding."

Uses (2)

Used by (1)