-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace the default wasm garbage collector with nottinygc #25
Conversation
I should confess one downside, which is that the wasm is significantly larger (+110KB) However, the performance was quite bad and I think this is an easy tradeoff. |
@anuraaga had a good idea about a start panic instead. maybe hold off and we can use a version that has an instructive error message even if still SDK users should copy/pasta the args to tinygo (or use a supplied script to invoke it) |
Updated |
ff159be
to
b9339fb
Compare
Thanks @anuraaga I updated like so
|
b9339fb
to
b465d61
Compare
so here's the current error if the plugin wasn't built with the flags:
|
@codefromthecrypt Oh, I wonder if printing the error message of a panic would require stderr/stdout to be available. That might make the approach not very applicable... |
this might be ok. lemme wire up and see |
@anuraaga I changed to prioritize stdout/stderr over a generic stack trace. If looks good I'll try to add a test of some kind:
|
In the server-side wasm, what gonna be the problem/disadvantage of a bigger wasm size? The performance to load the wasm in the host side? |
One reason is I think some people move wasm around with config maps? cc @salaboy about any size constraints there, in case folks here aren't aware of the nuance. Basically, we may be 110kb closer to that limit. Once past that limit, we need to use http refs like most proxy-wasm are moved around by istio (OCI is another way, such as what trivy does). |
Yeah configMaps have size restrictions, but also you are storing those
files in etcd, which was not designed for storing files (in the context of
kubernetes) , saving wasm files in volumes is the way to go
On Sat, 3 Jun 2023 at 06:59, Crypt Keeper ***@***.***> wrote:
In the server-side wasm, what gonna be the problem/disadvantage of a
bigger wasm size? The performance to load the wasm in the host side?
One reason is I think some people move wasm around with config maps? cc
@salaboy <https://github.com/salaboy> about any size constraints there,
in case folks here aren't aware of the nuance. Basically, we may be 110kb
closer to that limit. Once past that limit, we need to use http refs like
most proxy-wasm are moved around by istio (OCI is another way, such as what
trivy does).
—
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACCMXXVQIG4DWIDDSNM4DLXJLAERANCNFSM6AAAAAAYVGRKSE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
- Blog: http://salaboy.com <http://salaboy.wordpress.com>
- Github user: http://github.com/salaboy
- Twitter: http://twitter.com/salaboy
- Mauricio "Salaboy" Salatino -
|
I'll go ahead and add the unit test here and also add an issue for docs on how to handle wasm distribution |
f8774d4
to
00ef31c
Compare
ok I backfilled tests for panic messages PTAL! |
@@ -23,6 +23,7 @@ import ( | |||
_ "k8s.io/component-base/metrics/prometheus/clientgo" // for rest client metric registration | |||
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration | |||
"k8s.io/kubernetes/cmd/kube-scheduler/app" | |||
wasm "sigs.k8s.io/kube-scheduler-wasm-extension/scheduler/plugin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this broke earlier. After this PR is in I will setup CI to test all the src directories.
node: testdata.NodeSmall, | ||
expectedCode: framework.Error, | ||
expectedMessage: `wasm: filter error: panic! | ||
wasm error: unreachable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used manual webassembly (%.wat) because it is easier to reach error conditions and has stable stack traces. The wasm binaries are tiny so we can create a bunch of these if we need to.
if results, err := g.filterFn.Call(ctx); err != nil { | ||
return framework.AsStatus(err) | ||
return framework.AsStatus(decorateError(g.out, "filter", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this might literally save some prototypers' lives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to do the same in http-wasm, I'm really glad you reminded me where panics go to die :)
00ef31c
to
a1fc0c3
Compare
rebased |
45fb1c1
to
6fe0dc9
Compare
added a |
/lgtm Free free to unhold this. |
I will add a RATIONALE section then ping @sanposhiho for final review |
6fe0dc9
to
ab9d106
Compare
PTAL I added the RATIONALE.md cc also @anuraaga to keep me honest if I mentioned pros/cons correctly! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! RATIONALE.md is as usual a great read
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anuraaga, codefromthecrypt, kerthcet The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
After profiling, I noticed over half the time in wasm was spent in garbage collection. This could have been guessed, but it was nice to verify it with wzprof. This uses an optimized garbage collector, nottinygc, dramatically improving performance. Signed-off-by: Adrian Cole <adrian@tetrate.io>
eb5f433
to
57768f4
Compare
squashed |
/hold cancel |
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
After profiling in #24, I noticed over half the time in wasm was spent in garbage collection. This could have been guessed, but it was nice to verify it with wzprof.
This uses an optimized garbage collector, nottinygc, dramatically improving performance.
Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
https://github.com/wasilibs/nottinygc was invented by the excellent @anuraaga
Does this PR introduce a user-facing change?
NONE
What are the benchmark results of this change?
same code takes half the time!