Skip to main content

Module config

Module config 

Source
Expand description

Configuration constants for nalloc.

This module centralizes all tunable parameters and magic numbers to make the allocator easily configurable.

Constantsยง

CACHE_LINE_ALIGN
Cache line size for SIMD-friendly FFT/NTT operations. 64 bytes is optimal for AVX-512 and most modern CPUs.
DEFAULT_ALIGN
Default minimum alignment for all allocations.
GUARD_PAGE_SIZE
Size of guard pages (usually one page).
HUGE_PAGE_1GB
1GB huge page size (Linux, requires explicit kernel config).
HUGE_PAGE_2MB
2MB huge page size (Linux).
LARGE_ALLOC_THRESHOLD
Allocations larger than this threshold go to the Polynomial Arena. Smaller allocations go to the Scratch Arena via GlobalAlloc.
MAX_CAS_RETRIES
Maximum number of CAS retries before giving up (for extreme contention). On CI runners with 2 CPUs and 8 concurrent threads the initialising thread can be starved, so we allow many more iterations. Each outer loop now also calls thread::yield_now() every 10 iterations so the OS can schedule the thread that is actually doing the initialisation work.
PAGE_ALIGN
Page alignment for huge vector allocations. 4KB works across Linux, macOS, and Windows.
POISON_PATTERN
Pattern used for memory poisoning in debug builds. 0xDE is a distinctive pattern that helps identify use-after-free.
POLY_ARENA_SIZE
Size of the Polynomial Arena in bytes. Used for FFT/NTT coefficient vectors - needs to be large for complex circuits.
SCRATCH_ARENA_SIZE
Size of the Scratch Arena in bytes. Used for temporary computation buffers.
SECURE_WIPE_PATTERN
Secure wipe pattern (zero is standard for cryptographic applications).
SPIN_ITERATIONS
Spin loop hint iterations before each state check.
WITNESS_ARENA_SIZE
Size of the Witness Arena in bytes. Used for private ZK inputs requiring secure wiping.