pchickey opened PR #2946 from pch/eager_per_thread_init
to main
:
Based on #2897 - draft until that lands
In the Tokio runtime and elsewhere, it is useful to eagerly initialize thread-local resources (signal handlers etc) to avoid taking a runtime hit after a service is started.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
pchickey requested alexcrichton for a review on PR #2946.
alexcrichton submitted PR review.
pchickey updated PR #2946 from pch/eager_per_thread_init
to main
.
pchickey has marked PR #2946 as ready for review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
This could probably be a bit simpler with
if initialized { return }
and thenp.set((state, true))
afterwards
pchickey updated PR #2946 from pch/eager_per_thread_init
to main
.
pchickey updated PR #2946 from pch/eager_per_thread_init
to main
.
pchickey updated PR #2946 from pch/eager_per_thread_init
to main
.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
As a suggestion for a doc block here:
Eagerly initialize thread-local functionality shared by all [
Engine
]s.Wasmtime's implementation on some platforms may involve per-thread setup that needs to happen whenever WebAssembly is invoked. This setup can take on the order of a few hundred microseconds, whereas the overhead of calling WebAssembly is otherwise on the order of a few nanoseconds. This setup cost is paid once per-OS-thread. If your application is sensitive to the latencies of WebAssembly function calls, even those that happen first on a thread, then this function can be used to improve the consistency of each call into WebAssembly by explicitly frontloading the cost of the one-time setup per-thread.
Note that this function is not required to be called in any embedding. Wasmtime will automatically initialize thread-local-state as necessary on calls into WebAssembly. This is provided for use cases where the latency of WebAssembly calls are extra-important, which is not necessarily true of all embeddings.
pchickey updated PR #2946 from pch/eager_per_thread_init
to main
.
pchickey submitted PR review.
pchickey created PR review comment:
Thanks! That doc, and the bench docs, are now pushed.
alexcrichton submitted PR review.
pchickey updated PR #2946 from pch/eager_per_thread_init
to main
.
pchickey merged PR #2946.
Last updated: Nov 22 2024 at 16:03 UTC