stylus-profiler: budget your 24KB before you hit the wall

Arbitrum Stylus has a hard 24KB compressed-WASM limit. Most teams blow past it without warning. stylus-profiler tells you which functions ate your budget — before deploy.

stylus-profiler
Open-source · Rust · MIT

The 24KB cliff

Arbitrum Stylus lets you write smart contracts in Rust, compile to WASM, and run them on Arbitrum at a fraction of EVM gas costs. The catch nobody mentions in the marketing: there's a hard 24KB compressed binary size limit. 128KB uncompressed. Hit either, and your contract is undeployable.

Standard Rust patterns blow past this. A naive ERC-20 implementation with derive macros and a few helper traits will end up at 30-40KB compressed. The Stylus toolchain tells you you're over the limit but not why. You're left binary-bisecting your code to find the culprit.

What stylus-profiler does

Four commands, all single-shot:

  • analyze — full report: size, structure, top functions, gas estimates
  • size — function-by-function size breakdown, sorted
  • compare — diff two builds to catch regressions in CI
  • optimize — suggests debug sections to strip, inlining opportunities, unused imports

Output is a clean table you can read at a glance: how much headroom you have, which functions are eating the budget, what's worth refactoring first.

Why this is the second tool in the suite

stylus-profiler joins arbitrum-cli as the second piece of the kcolbchain Arbitrum-developer toolkit. Same conventions: single Rust binary, no service to run, install with one cargo install. The third piece, superchain-trace, ships alongside this for OP Superchain debugging.