Documentation
¶
Index ¶
- Constants
- func ApplySelfRLimits(cpuSeconds, memoryBytes uint64) error
- func AvailableMemoryMB() uint64
- func CPURlimitExceeded(err error) bool
- func CompileFFI(sierra *starknet.SierraClass) (*starknet.CasmClass, error)
- func ConcurrencyLimit(maxConcurrency uint64, availableMemory uint64, nodeMemoryReserve uint64, ...) uint64
- type Compiler
- type Config
Constants ¶
const ( FlagMaxMemory = "max-memory" // bytes (RLIMIT_AS) FlagMaxCPUTime = "max-cpu-time" // seconds (RLIMIT_CPU) )
Flag names used to pass per-compilation resource limits to the compile-sierra child process. They are shared by the parent (which builds the child's argv) and the child command (which defines the flags and applies the limits to itself).
Variables ¶
This section is empty.
Functions ¶
func ApplySelfRLimits ¶ added in v0.16.3
ApplySelfRLimits caps the CPU time (RLIMIT_CPU, seconds) and address space (RLIMIT_AS, bytes) of the calling process. A zero value leaves the corresponding limit unchanged.
It is called by the compile-sierra child at startup, before any compilation work, so the limits are in force for the whole compile with no race window. unix.Setrlimit applies process-wide on Linux.
func AvailableMemoryMB ¶ added in v0.16.6
func AvailableMemoryMB() uint64
AvailableMemoryMB returns the RAM this process can use, in MB. It checks if the memory is limited by the cgroup limit, otherwise it uses the host RAM.
func CPURlimitExceeded ¶ added in v0.16.3
CPURlimitExceeded reports whether err indicates the compile-sierra child was killed by the kernel for exceeding an applied rlimit: RLIMIT_CPU raises SIGXCPU and then SIGKILL. It turns the otherwise opaque "signal: killed" exec error into a diagnosable resource-limit message.
func CompileFFI ¶ added in v0.15.20
func CompileFFI(sierra *starknet.SierraClass) (*starknet.CasmClass, error)
CompileFFI performs Sierra-to-CASM compilation via direct CGo FFI.
func ConcurrencyLimit ¶ added in v0.16.6
func ConcurrencyLimit( maxConcurrency uint64, availableMemory uint64, nodeMemoryReserve uint64, maxMemoryPerCompilation uint64, ) uint64
ConcurrencyLimit returns how many compilations fit in memory, capped by maxConcurrency. Memory is in MB. A 0 maxMemoryPerCompilation means no memory limit. Returns 1 when no compilation fits memory.
Types ¶
type Compiler ¶ added in v0.15.20
type Compiler interface {
Compile(ctx context.Context, sierra *starknet.SierraClass) (
*starknet.CasmClass, error,
)
}
Compiler compiles Sierra classes to CASM.
type Config ¶ added in v0.16.3
type Config struct {
// MaxMemory is the address-space limit (RLIMIT_AS) in bytes
// applied to each compilation process. Exceeding it aborts that
// compilation. Enforced on Linux only. 0 disables the limit.
MaxMemory uint64
// MaxCPUTime is the CPU-time limit (RLIMIT_CPU) in seconds
// applied to each compilation process. Exceeding it kills that
// compilation. Enforced on Linux only. 0 disables the limit.
MaxCPUTime uint64
}
Config bounds the resources used by compilation child processes.