#ckb #flame-graph #cycle #file #consumption #script #statistical

bin+lib ckb-vm-pprof

Statistical CKB script cycles consumption flame graph

11 releases (breaking)

new 0.119.0 Oct 25, 2024
0.118.0-rc1 Aug 28, 2024
0.117.0 Jul 30, 2024
0.115.0-rc2 Mar 21, 2024
0.112.1 Nov 22, 2023

#11 in #consumption

35 downloads per month

MIT license

795KB
527 lines

Contains (ELF exe/lib, 3MB) res/bench_pairing, (ELF exe/lib, 505KB) res/sprintf, (ELF exe/lib, 34KB) res/abc, (ELF exe/lib, 34KB) res/fib, (ELF exe/lib, 34KB) res/outofmemory, (ELF exe/lib, 35KB) res/sbrk

CKB VM PProf

This project profiling data in the format expected by the flamegraph visualization tool. It is a sub-project of ckb-vm.

Usage

Suppose the program to be tested is:

int fib(int n) {
    if (n == 0 || n == 1) {
        return n;
    } else {
        return fib(n-1) + fib(n-2);
    }
}

int main() {
    if (fib(10) != 55) {
        return 1;
    }
    return 0;
}

We should take the -g option on compiling for saving the debugging information:

$ riscv64-unknown-elf-gcc -g -o res/fib res/fib.c

To convert the textual representation of a flamegraph to a visual one, first install inferno:

$ cargo install inferno

Then, pass the file created by FlameLayer into inferno-flamegraph:

$ cargo run -- --bin res/fib | inferno-flamegraph > res/fib.svg

Open the svg:

Know more about ckb-vm-pprof

  • ckb-vm-pprof-converter: This project converts raw data emitted by ckb-vm-pprof to profile.proto format supported by pprof for detailed analysis.

Licences

MIT

Dependencies

~8.5MB
~159K SLoC