nupp.system

nupp.system reports four fixed ABI facts and estimates available parallelism. It retains the facts and selected query when the module loads.

const system = nupp.system

print(system.platform)              -- macos
print(system.architecture)          -- aarch64
print(system.endianness)            -- little
print(system.pointerBits)           -- 64
print(system.availableParallelism()) -- 10

Under emulation these describe the ABI actually executing, not the one being emulated, which is the pair generated code was built against. A browser reports the guest instruction set, while its endianness and pointer width remain little and 32.

Submodules

ModuleDescription
nupp.system.spiImplementation interface for environment facts.

Module contents

Values

ValueKindDescription
architecturevariableThe instruction set, by its canonical name.
availableParallelismvariableEstimates how many execution units this process may actually use.
endiannessvariableByte order: little everywhere Nupp runs today, or big.
platformvariableThe operating system, lowercase.
pointerBitsvariablePointer width for the executing ABI, either 32 or 64.

Values#

architecturevariable#

The instruction set, by its canonical name.

Names include aarch64, x86_64, x86, and wasm32. This is what is executing, so an x86_64 binary under Rosetta returns x86_64.

availableParallelismvariable#

Estimates how many execution units this process may actually use.

At least 1. Native hosts include operating-system restrictions in the estimate, while browser hosts use the value their browser exposes. It opens no worker pool, so it is a fair default for the limit one is opened with.

with scope = nupp.tasks.open(limit = nupp.system.availableParallelism()) do
    for _, shard in ipairs(shards) do
        scope:fork(shard, jobs.shard)
    end
end

endiannessvariable#

Byte order: little everywhere Nupp runs today, or big.

platformvariable#

const platform

The operating system, lowercase.

macos, linux, windows, bsd, or browser. An unrecognized host returns its own name lowercased rather than a placeholder, so a new platform reads as itself.

pointerBitsvariable#

Pointer width for the executing ABI, either 32 or 64.

The browser ABI is 32-bit even when its guest instruction set is not wasm32.