limits

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package limits centralises the env-driven memory ceilings declared in DECISIONS.md D007. Every cap has a default constant and a lookup helper that consults the matching PRISM_* environment variable.

The lookup helpers parse loudly. A non-empty env var that fails to parse, or that resolves to a non-positive value, is rejected by returning the default plus ok=false so callers can surface a config error rather than silently fall back. The companion Must* helpers return only the resolved value for callers that prefer the default- only behaviour.

Index

Constants

View Source
const (
	// DefaultTableMaxRows caps any single materialised *table.Table.
	// See PRISM_TABLE_MAX_ROWS.
	DefaultTableMaxRows = 50_000_000

	// DefaultJoinMaxRows caps the product of the two sides of a hash
	// join (left rows × right rows). See PRISM_JOIN_MAX_ROWS.
	DefaultJoinMaxRows = 5_000_000

	// DefaultRenderMaxMarks caps the number of marks the renderer
	// emits before auto-Sample injection. See PRISM_RENDER_MAX_MARKS.
	DefaultRenderMaxMarks = 100_000

	// DefaultQueryWorkers is the sentinel meaning "use runtime.NumCPU()".
	// Callers (plan.Execute) substitute NumCPU when QueryWorkers()
	// returns 0. See PRISM_QUERY_WORKERS.
	DefaultQueryWorkers = 0

	// DefaultTableCacheSize is the LRU capacity used by plan.NewLRU
	// when the env var is unset or invalid. See PRISM_TABLE_CACHE_SIZE.
	DefaultTableCacheSize = 256

	// DefaultWasmMaxBytes is the gzipped size ceiling enforced on the
	// compiled `bin/prism.wasm` artifact by the P17 size-budget gate.
	// See PRISM_WASM_MAX_BYTES.
	DefaultWasmMaxBytes = 16 * 1024 * 1024

	// SoftWarnWasmMaxBytes triggers a non-failing log message from the
	// size-budget gate when the binary creeps past 75% of the ceiling.
	// Crossing this threshold does not fail the build; only exceeding
	// DefaultWasmMaxBytes (or the env override) does.
	SoftWarnWasmMaxBytes = 12 * 1024 * 1024
)

Default ceilings. Keep these in sync with DECISIONS.md D007 and with design/05-dag-executor.md.

View Source
const (
	EnvTableMaxRows   = "PRISM_TABLE_MAX_ROWS"
	EnvJoinMaxRows    = "PRISM_JOIN_MAX_ROWS"
	EnvRenderMaxMarks = "PRISM_RENDER_MAX_MARKS"
	EnvQueryWorkers   = "PRISM_QUERY_WORKERS"
	EnvTableCacheSize = "PRISM_TABLE_CACHE_SIZE"
	EnvWasmMaxBytes   = "PRISM_WASM_MAX_BYTES"
)

Env var names. Exported so callers (CLI help text, error fixups) can reference the canonical names without typo risk.

Variables

This section is empty.

Functions

func JoinMaxRows

func JoinMaxRows() (int, bool)

JoinMaxRows mirrors TableMaxRows for the join-product ceiling.

func MustJoinMaxRows

func MustJoinMaxRows() int

MustJoinMaxRows mirrors MustTableMaxRows.

func MustQueryWorkers

func MustQueryWorkers() int

MustQueryWorkers mirrors MustTableMaxRows.

func MustRenderMaxMarks

func MustRenderMaxMarks() int

MustRenderMaxMarks mirrors MustTableMaxRows.

func MustTableCacheSize

func MustTableCacheSize() int

MustTableCacheSize mirrors MustTableMaxRows.

func MustTableMaxRows

func MustTableMaxRows() int

MustTableMaxRows returns the resolved cap, discarding the ok flag. Equivalent to the first return of TableMaxRows; useful at call sites that intentionally tolerate malformed env vars.

func MustWasmMaxBytes

func MustWasmMaxBytes() int

MustWasmMaxBytes mirrors MustTableMaxRows.

func QueryWorkers

func QueryWorkers() (int, bool)

QueryWorkers returns the requested parallel-executor worker count. 0 means "caller substitutes runtime.NumCPU()"; the second return is false when the env var was set but unparseable or non-positive. Unset env yields (0, true).

func RenderMaxMarks

func RenderMaxMarks() (int, bool)

RenderMaxMarks mirrors TableMaxRows for the render mark ceiling.

func TableCacheSize

func TableCacheSize() (int, bool)

TableCacheSize returns the LRU capacity for plan.TableCache. The second return is false when the env var was set but unparseable or non-positive; callers fall back to the default value (also returned in that case).

func TableMaxRows

func TableMaxRows() (int, bool)

TableMaxRows returns the effective cap for any single Table. The second return is false when the env var was set but unparseable or non-positive; callers may surface this as a PRISM_CONFIG_* error or silently fall back to the default value (also returned in that case).

func WasmMaxBytes

func WasmMaxBytes() (int, bool)

WasmMaxBytes returns the gzipped-size ceiling enforced on `bin/prism.wasm`. The second return is false when the env var was set but unparseable or non-positive; callers fall back to the default value (also returned in that case).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL