Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 8720a65

Browse files
committed
README: edit goroutine limitation
Signed-off-by: mathetake <[email protected]>
1 parent 30f389e commit 8720a65

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,23 @@ make test.e2e # run e2e tests
9292
2. TinyGo does not implement all of reflect package([examples](https://github.com/tinygo-org/tinygo/blob/v0.14.1/src/reflect/value.go#L299-L305)).
9393
3. [proxy-wasm-cpp-host](https://github.com/proxy-wasm/proxy-wasm-cpp-host) has not supported some of WASI APIs yet
9494
(see the [supported functions](https://github.com/proxy-wasm/proxy-wasm-cpp-host/blob/master/include/proxy-wasm/exports.h#L134-L147)).
95-
For example, `clock_time_get` is not implemented, and therefore we cannot use `time.Now`.
95+
For example, `clock_time_get` is not implemented, and therefore we cannot use `time.Now` function.
9696
- These issues will be mitigated as TinyGo and proxy-wasm-cpp-host evolve.
97-
- There's performance overhead in using Go/TinyGo due to GC
98-
- runtime.GC() is called whenever the heap runs out (see [1](https://tinygo.org/lang-support/#garbage-collection),
97+
- There's performance overhead of using Go/TinyGo due to GC
98+
- `runtime.GC` is called whenever the heap runs out (see [1](https://tinygo.org/lang-support/#garbage-collection),
9999
[2](https://github.com/tinygo-org/tinygo/blob/v0.14.1/src/runtime/gc_conservative.go#L218-L239)).
100100
- TinyGo allows us to disable GC, but we cannot do that since we need to use maps (implicitly causes allocation)
101-
for saving the plugin's [state](https://github.com/tetratelabs/proxy-wasm-go-sdk/blob/master/proxywasm/vmstate.go#L17-L22).
101+
for saving the plugin's [state](https://github.com/tetratelabs/proxy-wasm-go-sdk/blob/cf6ad74ed58b284d3d8ceeb8c5dba2280d5b1007/proxywasm/vmstate.go#L41-L46).
102102
- Theoretically, we can implement our own GC algorithms tailored for proxy-wasm through `alloc(uintptr)` [interface](https://github.com/tinygo-org/tinygo/blob/v0.14.1/src/runtime/gc_none.go#L13)
103103
with `-gc=none` option. This is the future TODO.
104104
- `recover` is [not implemented](https://github.com/tinygo-org/tinygo/issues/891) in TinyGo, and there's no way to prevent the WASM virtual machine from aborting.
105-
- Be careful about using Goroutine
105+
- Goroutine support
106106
- In Tinygo, Goroutine is implmeneted through LLVM's coroutine (see [this blog post](https://aykevl.nl/2019/02/tinygo-goroutines)).
107-
- Make every goroutine exit as soon as possible, otherwise it will block the proxy's worker thread. That is too bad for processing realtime network requests.
108-
- We strongly recommend that you implement the `OnTick` function for any asynchronous task instead of using Goroutine so we do not block requests.
107+
- In Envoy, WASM modules are run in the event driven manner, and therefore the "scheduler" is not executed once the main function exits.
108+
That means you cannot have the expected behavior of Goroutine as in ordinary host environments.
109+
- The question "How to deal with Goroutine in a thread local WASM VM executed in the event drive manner" has yet to be answered.
110+
- We strongly recommend that you implement the `OnTick` function for any asynchronous task instead of using Goroutine.
111+
- The scheduler can be disabled with `-scheduler=none` option of TinyGo.
109112

110113
## references
111114

0 commit comments

Comments
 (0)