-
Notifications
You must be signed in to change notification settings - Fork 152
Memory leak when using GetHttpRequestHeaders #349
Comments
cc @anuraaga this may be of your interest? |
Are any further details required? Is |
just to clarify: this seems TinyGo's GC issue, not the SDK's. |
Hi @ggmm-0 - we've been doing some heavy processing with TinyGo in https://github.com/corazawaf/coraza-proxy-wasm and found many performance problems, one was indeed the default GC. Eventually it gets fragmented and leads to OOM for any heavy workload as far as I can tell - it's not clear to me if this is a bug in the GC or just the nature of its simple (tiny) algorithm, but I think the latter. In coraza-proxy-wasm, we use a complicated mechanism for replacing the GC with the more robust bdwgc, including a custom build of TinyGo. https://github.com/corazawaf/coraza-proxy-wasm/tree/main/internal/gc and stopped having obvious memory problems. I have a PR out to TinyGo to allow custom GC packages that is stuck in review, if this were in it'd be simple to create a I will probably go ahead and send a PR to add an actual |
So yeah this is not an issue of SDK, closing. Thanks @anuraaga! |
@anuraaga, thanks for the detailed explanation. Do you expect tinygo-org/tinygo#3302 to be merged anytime soon? |
@anuraaga nottinygc works like a charm in high-load scenarios! Many thanks for your contributions! |
@anuraaga, nice and thank you! |
nice and thank you! nottinygc is good |
Describe the bug / error
It seems that memory allocated for the headers (when using
proxywasm.GetHttpRequestHeaders()
) is never freed up. The memory keeps growing linearly.When Envoy process consumes e.g. 800 MB, Envoy
/memory
endpoint reports only ~45-50 MB (also its heap dump shows the same) - that is why I suspect Wasm allocated heap (which I believe isn't reported by Envoy). Removingproxywasm.GetHttpRequestHeaders()
from the snippet below gets rid of the problem (stable 45-50 MB memory consumption by the whole process).What is your Envoy/Istio version?
Envoy built from source (commit
be8e01e
from 14 Oct, 2022: envoyproxy/envoy@be8e01e).What is the SDK version?
github.com/tetratelabs/proxy-wasm-go-sdk v0.20.0
What is your TinyGo version?
TinyGo from official docker image:
tinygo/tinygo:0.26.0
.URL or snippet of your code including Envoy configuration
I'm including the full example as it is a tiny sample application with a few custom lines. Most of it are proxywasm overrides and the actual code is in
OnHttpRequestHeaders
:Relevant Envoy config:
The text was updated successfully, but these errors were encountered: