performance/unused_result.bend fails
raw source on the hub · import bend-lint-rules@0.1.0.0/performance/unused_result.bend as Unused_result
performance/unused_result: a value that a loop binds and never uses, and that is data, not a number: a
lambda's parameter or a let's name, in a definition that calls itself. Bend computes every value it
binds, so this one is built, and then walked to be freed, on every step.
Heuristics: measured on llama.bend (SmolLM2-135M, CPU): its generation loop binds each layer's
activations and never uses them; building them empty made each token 19% to 25% faster, with the same
tokens. The cost grows with the value: a small one costs little to ignore. It reads how often the
checker found each binder used, and the type it gave it; numbers, and records of numbers only, are
those of performance/gpu_fit, and cost nothing to drop. An erased binder holds nothing at run time,
and a step of a do block (x : T <- m, a call of a bind) gets its value from the monad, used or not.
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
The reader could not load this file (at 0x2b0a0dcada30f71a8eb4ec2e148b9279/linter/lint.bend:522). What bend.ts says:
Error:
- expected : a fresh constructor name (duplicate declaration: Text)
- observed : 'Text'
Location:
521 | Flag{on: Bool}
522>| Text{text: String}
| ^^^^
523 |