Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Wasmi execution profiling #973

Open
Robbepop opened this issue Apr 2, 2024 · 1 comment · May be fixed by #974
Open

Add Wasmi execution profiling #973

Robbepop opened this issue Apr 2, 2024 · 1 comment · May be fixed by #974
Labels
enhancement New feature or request

Comments

@Robbepop
Copy link
Collaborator

Robbepop commented Apr 2, 2024

Currently there is no out-of-the-box way to profile Wasm executions via Wasmi.

One way this could look like is to collect information during Wasm executions such as total number of Wasmi instructions executed, total number of branches taken, total time spent in host functions, total instruction dispatch time, and for each instruction number of its execution and total execution time.

We could collect all this information in a singular struct during execution.
In order to not compromise performance we must put this functionality behind a crate feature profiling. This functionality must not degrade performance when not enabled. Ideally it would not even significantly degrade performance when enabled but this is probably a pipedream.

The Wasmi CLI should expose this functionality to its users.
This data enables Wasmi users and developers alike to better understand performance issues in their Wasm blobs or the Wasmi engine itself and to optimize for specific use cases.

Since the Wasmi bytecode enum is extremely large it might be a good idea to write a proc. macro to generate the associated profiling struct type from it to simplify keeping everything in sync.

After a Wasmi execution the profiler then outputs its collected data to the user. This could be formatted as JSON or something similar.

{
    "dispatch": {
        "time": "1.52s",
    },
    "host": {
        "time": "0.71s",
    },
    "instructions": {
        "i32.add": {
            "count": 3948,
            "time": "0.5us",
        },
        "branch": {
            "count": 995,
            "time": "0.1us",
        },
        etc ...
    }
}
@Robbepop Robbepop added the enhancement New feature or request label Apr 2, 2024
@Robbepop Robbepop linked a pull request Apr 2, 2024 that will close this issue
5 tasks
@orsinium
Copy link
Contributor

orsinium commented Apr 6, 2024

Might be related: wasmerio/wasmer#4381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants