-
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
Use wire-type compatible source in TinyGo #17
Use wire-type compatible source in TinyGo #17
Conversation
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.
note: using realistic protos increases the base wasm binary size in tinygo to 756KB. Future work may be able to optimize this back without losing features, but it is worth saying this part now.
ps here is the output from the makefile. Note there are warnings about schema not being in use, but as they are _ imported you would have to change the source to exclude it. $ make update-kubernetes-proto
cd ./kubernetes/proto/tools; \
cat tools.go | grep "_" | awk -F'"' '{print $2}' | xargs -tI % go install %
go install github.com/knqyf263/go-plugin/cmd/protoc-gen-go-plugin
go install google.golang.org/protobuf/cmd/protoc-gen-go
echo "Regenerate the Go protobuf code."
Regenerate the Go protobuf code.
cd kubernetes/kubernetes/staging/src/; \
protoc ./k8s.io/apimachinery/pkg/api/resource/generated.proto --go-plugin_out=../../../proto \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/api/resource/generated.proto=./resource; \
protoc ./k8s.io/apimachinery/pkg/runtime/generated.proto --go-plugin_out=../../../proto \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/runtime/generated.proto=./runtime; \
protoc ./k8s.io/apimachinery/pkg/runtime/schema/generated.proto --go-plugin_out=../../../proto \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/runtime/schema/generated.proto=./schema; \
protoc ./k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto --go-plugin_out=../../../proto \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/apis/meta/v1/generated.proto=./meta \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/runtime/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/runtime \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/runtime/schema/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/schema; \
protoc ./k8s.io/apimachinery/pkg/util/intstr/generated.proto --go-plugin_out=../../../proto \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/util/intstr/generated.proto=./instr; \
protoc ./k8s.io/api/core/v1/generated.proto --go-plugin_out=../../../proto \
--go-plugin_opt=Mk8s.io/api/core/v1/generated.proto=./api \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/api/resource/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/resource \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/apis/meta/v1/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/meta \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/runtime/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/runtime \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/runtime/schema/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/schema \
--go-plugin_opt=Mk8s.io/apimachinery/pkg/util/intstr/generated.proto=sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/instr;
k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto:25:1: warning: Import k8s.io/apimachinery/pkg/runtime/schema/generated.proto is unused.
k8s.io/api/core/v1/generated.proto:27:1: warning: Import k8s.io/apimachinery/pkg/runtime/schema/generated.proto is unused. |
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.
One nit, leave it to @kerthcet.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: codefromthecrypt, sanposhiho 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 |
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
Thanks @codefromthecrypt Have a great flight!
protoc ./kubernetes/proto/kubernetes.proto \ | ||
--go-plugin_out=./kubernetes/proto --go-plugin_opt=Mkubernetes/proto/kubernetes.proto=./api | ||
cd kubernetes/kubernetes/staging/src/; \ | ||
protoc ./k8s.io/apimachinery/pkg/api/resource/generated.proto --go-plugin_out=../../../proto \ |
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 did this same before, it's annoying at this moment, but I prefer to use the native ones.
Please squash you commit it said you have invalid commit message. |
0b97387
to
b370ad3
Compare
Signed-off-by: Adrian Cole <adrian@tetrate.io>
b370ad3
to
cf03b72
Compare
ok I tried a different commit message 🤞 |
/lgtm |
Thanks for the fast feedback. now we are unlocked to do more modeling and performance work! |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Before, we had incompatible types, which among other things, made the POC difficult to reason with from a performance point of view. We were manually converting fields, which would never work in practice as the model is quite large.
This uses the real protos k8s does, just generating TinyGo compatible guest code from them. This now serializes the
v1.Pod
directly from the input type in a way TinyGo can get it. To eliminate a performance hit from filters that don't access the current pod, this extracts aFilterArgs
type. Doing so gives us flexibility in implementation, especially as we add more parameters later.Which issue(s) this PR fixes:
Fixes #13
Special notes for your reviewer:
This change slows down execution, but that's good because it is more realistic. Before we manually copied a single field, so the after is a better baseline. Note: this still doesn't use realistic data, but at least we can generate it now!