stdlib-js / www

Website for stdlib, a standard library for JavaScript and Node.js.
https://stdlib.io
Apache License 2.0
6 stars 8 forks source link

[RFC]: investigate using web workers for running tests and benchmarks, rather than iframes #35

Closed kgryte closed 2 years ago

kgryte commented 2 years ago

Description

This RFC proposes investigating using web workers for running tests and benchmarks, rather than iframes.

Currently, in order to run benchmarks and tests, we load an HTML page into an iframe, which then loads a benchmark or test bundle, respectively.

This approach works; however, it often results in blocking the main thread and potentially causing the current browser tab to lock and/or crash.

This RFC proposes potentially moving execution logic to a web worker. This should be doable, as tests and benchmarks do not interact with the DOM, nor should we necessarily expect them to in the future. In which case, all we really care about is their printed output, which can be passed back to the main thread via message passing.

Moving execution logic to a web worker would entail a different benchmark/test loading mechanism. Notably, we'd no longer load via an *.html file, but would likely need to load the benchmark/test bundles directly.

Were we to successfully move execution logic to a web worker, we would presumably need to prevent the user from moving to another package/view during execution, or need to do something to address an orphaned web worker.

For those browsers lacking web workers, we'd either need a fallback OR we'd need to show an error and/or hide tests/benchmarks from the UI altogether. The latter is probably the most straightforward.

Related Issues

No.

Questions

No.

Other

No.

Checklist

Planeshifter commented 2 years ago

This has meanwhile been accomplished. Closing.