Alternera. PluginWasmFramework. MemoryLimit
(alternera_plugin_wasm_framework v0.9.0)
Copy Markdown
View Source
A language step's "Memory limit" setting: how much memory the script's guest may use in one call. Guest memory is outside every BEAM limit, so the step says it, where whoever edits the pipeline sees it, and it travels with the step in exports and releases.
%{"mode" => "flat", "mib" => 4} # Flat: a number of MiB
%{"mode" => "body", "factor" => 8} # Body ×: a multiple of the body- Flat (
"flat"), the default at 4 MiB: a field-for-field JSON transform measured about 2 MiB on a 100 KB body and 6 MiB on a 500 KB one, so the default holds bodies up to about 300 KB; a step with larger ones raises it or takes Body ×. - Body × (
"body"): a multiple of the size of the body the step holds in its direction (the body only, not variables or inputs), from the language's starting multiple when someone switches to it (%Language{body_factor: …}, 8 unless the language says otherwise: Lua measured about seven times a decoded JSON body, JavaScript about ten, so it starts at 12), never under a floor of 8 MiB: a multiple of an empty body is nothing, and an interpreter needs a few MiB to start. A step that holds no body (reads_bodyoff) offers Flat only.
Over both sits the node's ceiling per call, max_memory_mib in the
framework's config (default 128): a save over it is refused with a
message that names it, and a Body × limit that grows past it on a large
body is held to it.
config :alternera_plugin_wasm_framework, max_memory_mib: 128The ceiling protects the node, so it is not a tenant or step setting.
Summary
Functions
The bytes one call may use under limit with a body of body_bytes:
the setting, the Body × floor under it and the node's ceiling over it.
The node's ceiling per call, in MiB (max_memory_mib).
The setting a step without one has: Flat, 4 MiB.
The multiple Body × starts at for a language that names none.
The setting in words, for a failure and the step's list: "Flat 4 MiB", "Body × 8".
The least a Body × limit gives, in MiB.
Checks a stored setting (nil is the default). reads_body? says whether
the step holds a body, without which Body × means nothing;
default_factor is the multiple a Body × setting without one takes,
the language's.
The setting stored back: what a step's settings hold.
Used of limit for the step's summary: "21 of 32 MiB", rounded up to whole MiB.
Types
@type t() :: {:flat, pos_integer()} | {:body, pos_integer()}
A checked setting.
Functions
@spec bytes(t(), non_neg_integer()) :: pos_integer()
The bytes one call may use under limit with a body of body_bytes:
the setting, the Body × floor under it and the node's ceiling over it.
@spec ceiling_mib() :: pos_integer()
The node's ceiling per call, in MiB (max_memory_mib).
@spec default() :: t()
The setting a step without one has: Flat, 4 MiB.
@spec default_factor() :: pos_integer()
The multiple Body × starts at for a language that names none.
The setting in words, for a failure and the step's list: "Flat 4 MiB", "Body × 8".
@spec floor_mib() :: pos_integer()
The least a Body × limit gives, in MiB.
@spec parse(term(), boolean(), pos_integer()) :: {:ok, t()} | {:error, String.t()}
Checks a stored setting (nil is the default). reads_body? says whether
the step holds a body, without which Body × means nothing;
default_factor is the multiple a Body × setting without one takes,
the language's.
The setting stored back: what a step's settings hold.
@spec usage(non_neg_integer(), pos_integer()) :: String.t()
Used of limit for the step's summary: "21 of 32 MiB", rounded up to whole MiB.