emscripten-core / emscripten-core/emscripten

emrun stdio performance

Open
#15,839 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

emrun stdio performance

I am compiling a legacy native library that also includes a large number of gtests. When running the gtest they write a lot to the stdio under emrun this is a performance bottleneck.

This bottle neck is created by emrun writing the stdio 3 places. the dom,console, and also posts an http request to the server.

Even eliminating the dom doesn't help because the writes can come so quickly the chrome will error because of so many requests being created.

In my example if i run the gtest wasm with --gtest_list_tests which does not run anything but lists the names of all the tests in the executable takes ~3 minutes with default emrun behavior.

By adding a simple `--extern-post-js` I am able to make the this take 1-2 seconds.

I am not sure if others have run into the stdio performance or not but this could be a useful feature to allow users to specify a stdio buffer limit

```js
var process = cb => {
var lines = [];
var limit = 1000;
return (text, flush) => {
lines.push(text);
if(flush || lines.length > limit) {
cb(lines.join('\n'));
lines = [];
}
};
}
out = process(out);
err = process(err);
addOnExit(() => {
out('', true);
err('', true);
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.