-
Notifications
You must be signed in to change notification settings - Fork 86
adaptation: allow compiling out WASM support altogether. #253
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
Conversation
| socketPath: DefaultSocketPath, | ||
| syncLock: sync.RWMutex{}, | ||
| wasmService: wasmPlugins, | ||
| wasmService: wasmService, |
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 was originally considering if this could be a functional option (WithWASMService); that could potentially allow the caller to either pass, or not pass the option.
Compile-time could still be an option for that if a stub WithWASMService was created (that would either return an error, or nil).
|
Oh, thanks! @robmry PTAL 🤗 The thing I was struggling with was that various of the WASM types are also deeply engrained in the API definition, but not sure if that caused the binary size to grow as well. I started looking if we could somehow get that dependency out of the API definition, but didn't get very far; just a quick "let's see if this could work", but there were a lot of places and additional definitions; I pushed what I had here, but it very likely won't even compile; edit: wrong link |
9b9b452 to
b5c71f1
Compare
Yeah, I'm unable to tell. But I tried the effect of this and compiling containerd main/HEAD now with BUILDTAGS=nri_nowasm results on x86_64 in a 45272408 binary size vs. 48184952 when compiling with WASM support enabled. A size reduction of 2912544 bytes. |
thaJeztah
left a comment
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!
I think this change looks good; AFAICS, it doesn't paint us in a corner on considering some of the other options (functional option to add the plugin and looking further at what can be done for the API definitions).
I left one nit for the naming of the files, but not really blocking, just a suggestion.
LGTM
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 think using underscores instead of hyphens is more common in Go; perhaps adaptation_wasm.go and adaptation_nowasm.go could work?
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 think that calling it adaptation_wasm.go would not work. It would break the builds, because wasm is a valid GOARCH, so it would be excluded from x86_64 and arm builds.
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.
Oh! good call, forgot that wasm was a builtin... 😢
Yes, I also think we should explore your 'inject WASM support using a functional option' further, and see if we can sort everything out to get it working, and then take a look at what that would mean in terms of maintenance wrt. expected WASM runtime API stability/etc. |
Great - thank you! I tried it on a dockerd build and it saves about the same. |
nod.. I wonder if functional would allow for variants per runtime type? |
|
@saschagrunert Would you guys be okay with enabling WASM support behind a build flag and have it disabled by default (so the other way around than proposed in this PR) ? |
AkihiroSuda
left a comment
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.
The build tag seems inconsistent with existing ones
https://github.com/containerd/nri/pull/253/changes#r2612981454
If you mean plugging in other WASM implementations than wazero, then moving to a functional option to set up WASM support would make this theoretically/from a pure mechanics PoV possible. However, since our WASM support uses knqyf263/go-plugin to generate all the necessary bindings and other boilerplate to interact with WASM-compiled code from our protobuf definitions, and since go-plugin uses wazero, this would not really be possible in practice at the moment. |
Should be fine, yes. |
b5c71f1 to
e10f3bf
Compare
AkihiroSuda
left a comment
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
marquiz
left a comment
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.
Looks good to me.
That said, if we think that disabling wasm support by default is desirable and a good thing, I think now would be a good time to do it (before we get to NRI v1.0). Put a big fat note in the release notes.
mikebrow
left a comment
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.
LGTM
I think disabling WASM makes the most sense for those who consume and compile containerd themselves from sources and really count bytes, for instance k3s. I'd be fine with keeping it enabled by default. |
Allow WASM support to be disabled at compile time using the "nri_no_wasm" build tag. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
e10f3bf to
ab88fe6
Compare
|
@AkihiroSuda Updated the build tag according to the latest preference/review comment. Now I'd need one re-approval to be able to merge this. |
This PR introduces the "nri_no_wasm" build tag which now allows disabling WASM support altogether at compile time. This can be helpful in resource constrained or other environments, where WASM support is not needed and the related binary size increase penalty is considered difficult to justify.