ejrgilbert / whamm

Debugging WebAssembly? Put some Whamm! on it.
https://ejrgilbert.github.io/whamm/
16 stars 3 forks source link

Sampling support #138

Open ejrgilbert opened 3 months ago

ejrgilbert commented 3 months ago

This is dependent on #135.

We could do some sugaring to expand simple sampling logic for probes. Consider:

wasm:opcode:if:before {
    local int fire;
    if fire == 0 {
        ... // probe body
        count = rand() % 1000;
    }
    fire--;
}

We could sugar this to:

wasm:opcode:if:sample-1000 {
    ... // probe body
}

More complex examples (requires more language features)

There are also some other more-complex sampling techniques, e.g. reservoir sampling, that could be implemented and made available through just implementing them in the whamm library. So, the sampling logic would exist in whamm's Rust library, which is called to check if the probe should be fired.