Skip to content

Use optimized 256-bit instructions - #604

Draft
elle-j wants to merge 12 commits into
cl/custom-opsfrom
lj/custom-ops-256-opt
Draft

Use optimized 256-bit instructions#604
elle-j wants to merge 12 commits into
cl/custom-opsfrom
lj/custom-ops-256-opt

Conversation

@elle-j

@elle-j elle-j commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Windows.

A workspace-wide resolve checks out the temporary polkadot-sdk git
dependency, whose tree contains a directory named aux — a reserved
device name on Windows — so the checkout fails before the builder is
even installed.

The builder itself uses no workspace crate and no git dependency, so
narrowing the workspace members to crates/llvm-builder keeps the resolve
entirely on crates.io; the narrowed resolve no longer matches
Cargo.lock, which is why the Windows install drops --locked.
The MSVC developer environment makes rustc invoke the linker by the bare
name link.exe, and bash prepends the Git coreutils link.exe to PATH
ahead of the MSVC one, so every build script failed to link. The
workspace narrowing stays in bash for grep and sed; only the cargo
install moves back to the default shell, where link.exe resolves to
MSVC.
Workflows will temporarily use prebuilt fork LLVM supporting the wide
instructions. Differential tests will run both with the interpreter and
the JIT, allowing testing the recompiler/JIT runs (x86-64 dependent) via
CI before running any benchmarks.

The JIT leg differs only in RUSTFLAGS gaining --cfg revive_jit, which
is_jit reads and the dev-node runtime build script propagates into the
wasm build on its own. For the first run, the JIT leg passes no
expectations file as it first needs a baseline from the uploaded report.
Allows starting the resolc builds immediately.
The e2e node built from cccda66 embeds polkavm 09ce634, whose recompiler corrupts the heap while emitting the wide instructions and wedged under the JIT leg. This commit pins the fixed polkavm 77373b5.
The PolkaVM blob writer sized its jump table entries by counting bytes up to the first zero of the target offset. Thus, a program whose code crosses 64 KiB could deploy with a target truncated to an offset that is not an instruction boundary, which parses and then traps on the first return through it.
The previous revision reduces the 256-bit division family through
bit-serial loops of up to 512 iterations per mulmod, which dominate wide
instruction execution time on both backends. The new revision computes
identical results digit-serially in roughly a seventh of the executed
instructions per mulmod.
The renamed test-sim module removes the directory that libgit2 refuses
to write on Windows, which made any workspace resolve with the git
dependency present fail there. The temporary narrowed LLVM builder
install on Windows existed only to avoid that checkout, so it is removed
together with the bump.
The new revision monomorphizes the division digit step per divisor
width, estimates quotients with a table seeded reciprocal, gives
single-limb operands a native division path, and skips limbs the product
does not occupy in the full-width modulus reduction, removing a quarter
to three quarters of the executed instructions per operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant