~/bend-docscommunity

performance/deep_call_in_fork.bend fails

raw source on the hub · import bend-lint-rules@0.1.0.0/performance/deep_call_in_fork.bend as Deep_call_in_fork

performance/deep_call_in_fork: a fork that calls a definition that calls itself outside a tail position. A value of a parallel let (a b = f(x) g(y)), or of a let just before it, calls a definition of the file whose call of itself is not the last thing it does. Heuristics: Bend gives a call of itself that is not a tail call a frame per call ("bend guide shaders"). In bend-lint's benchmark (Bend 2.0.36, on the CPU), such a call at each fork cut the speedup from 10x to 1.9x; the same definition with a tail call kept the 10x. In a raytracer that splits its rows that way at each of 9 fork levels, tail-recursive splits made it 4% to 8% faster on the CPU; in Bend's slash boss demo, the same change changed no timing, as its list was short. The JS lane is not measured. A tail position is the body of a definition, a case, or the rest of a block after its lets, through annotations. A definition with a parallel let is a fork tree: its calls of itself are the values of its forks, not frames, and it is not reported (Bend's matrix and Merkle benchmarks call such trees in their forks).

4 imports
import Base
import bend-lint-api@0.1.0.0/linter/lint.bend as Lint
import bend-lint-api@0.1.0.0/shared/lists.bend as Lists
import ./gpu_fit.bend as GpuFit