Docs

Budgets in code

berm_lang::limit lowers the running call's CPU, rows and memory budget, for that call alone, so a tool bills only the memory its arguments need.

berm_lang::limit(0, 0, 0, 4 << 20)?;
  • berm_lang::limit(cpu, read, written, memory) lowers the running call's budget, for that call alone: CPU in microseconds, rows read, rows written, memory in bytes, 0 keeping each. The tool's budget stays as its crab.toml sets it.
  • A call lowers it once. A second time is refused, as is a value past the budget or memory below what the call holds already.
  • Memory is billed at the budget until the call lowers it and at the lower one after, so a tool that can tell from its arguments how much it needs lowers it before doing the work.

Setting a tool's budget and what happens past it: Budgets.