https://github.com/m-kus/scarb-burn
🔥 Scarb extension for generating Cairo flamegraphs
https://github.com/m-kus/scarb-burn
cairo flamegraph pprof profiler scarb starknet
Last synced: about 2 months ago
JSON representation
🔥 Scarb extension for generating Cairo flamegraphs
- Host: GitHub
- URL: https://github.com/m-kus/scarb-burn
- Owner: m-kus
- License: mit
- Created: 2025-01-29T18:54:19.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-02-17T18:05:10.000Z (3 months ago)
- Last Synced: 2025-02-17T19:24:00.648Z (3 months ago)
- Topics: cairo, flamegraph, pprof, profiler, scarb, starknet
- Language: Rust
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scarb Burn
Scarb extension for generating Cairo flame charts and pprof profiles.

This is a complementary tool to [cairo-profiler](https://github.com/software-mansion/cairo-profiler), focused on generic Cairo programs run outside of Starknet context. It is particularly useful if you have a program that consumes a large arguments file.
## Installation
You need to have Rust installed on your machine.
```bash
cargo install --git https://github.com/m-kus/scarb-burn scarb-burn
```## Usage
Run in your project directory:
```bash
# Generate flamegraph (default)
scarb burn --arguments-file arguments.json --output-file flamegraph.svg --open-in-browser# Generate pprof profile (requires Go toolchain for visualization)
scarb burn --output-type pprof --output-file profile.pb.gz --arguments-file arguments.json --open-in-browser
```## Output Types
- **flamegraph**: Interactive SVG visualization, no additional dependencies required
- **pprof**: Google's profiling format, requires Go toolchain for visualization but provides more analysis tools## Notes
- Only `main` entrypoint wrapped with `#[executable]` attribute is supported, you also have to have `[lib]` target in Scarb.toml so that a Sierra file is generated
- Arguments format is compatible with `scarb execute` but not with `scarb cairo-run`
- User and corelib as well as libfuncs are counted, providing the most detailed info
- Loops and recursive calls are collapsed to improve readability
- `--open-in-browser` opens SVG directly for flamegraphs, starts pprof web UI on port 8000 for pprof files
- `--no-build` flag to skip rebuilding the package## Arguments Format
Arguments can be provided via file (--arguments-file) or command line (--arguments):
```json
["0x1234", "0x5678"] // arguments.json example
```Note that main executable wrapper has a single argument of type `Array` containing inner arguments serialized with Cairo Serde.