kubernetes-sigs / kube-scheduler-wasm-extension

All the things to make the scheduler extendable with wasm.
Apache License 2.0
86 stars 17 forks source link

Add api.Plugin as a base type for guest plugins #54

Closed codefromthecrypt closed 10 months ago

codefromthecrypt commented 10 months ago

What type of PR is this?

/kind cleanup /kind documentation

What this PR does / why we need it:

This adds api.Plugin as a base type for guest plugins. This is similar to framework.Plugin, but doesn't yet define Name() as there's no purpose for it. Notes on that are added to RATIONALE.md.

This mostly gets the guest SDK looking much more like the framework one. This also makes it easier to test for misconfiguration, such as registering multiple instances of plugins.

Which issue(s) this PR fixes:

NONE

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE because it isn't user-ready yet!

What are the benchmark results of this change?

goos: darwin
goarch: arm64
pkg: sigs.k8s.io/kube-scheduler-wasm-extension/internal/e2e
                                                        │ before.txt  │              now.txt               │
                                                        │   sec/op    │   sec/op     vs base               │
PluginPreFilter/noop-wat/params:_small-12                 132.1n ± 1%   133.0n ± 1%        ~ (p=0.905 n=6)
PluginPreFilter/noop-wat/params:_real-12                  132.6n ± 3%   132.4n ± 2%        ~ (p=0.556 n=6)
PluginPreFilter/noop/params:_small-12                     296.9n ± 0%   278.7n ± 1%   -6.15% (p=0.002 n=6)
PluginPreFilter/noop/params:_real-12                      297.2n ± 0%   278.3n ± 0%   -6.36% (p=0.002 n=6)
PluginPreFilter/test/params:_small-12                     4.401µ ± 1%   4.312µ ± 1%   -2.01% (p=0.002 n=6)
PluginPreFilter/test/params:_real-12                      49.79µ ± 0%   48.48µ ± 1%   -2.65% (p=0.002 n=6)
PluginFilter/noop-wat/params:_small-12                    266.1n ± 0%   271.7n ± 3%        ~ (p=0.165 n=6)
PluginFilter/noop-wat/params:_real-12                     266.9n ± 0%   270.9n ± 2%        ~ (p=0.225 n=6)
PluginFilter/noop/params:_small-12                        482.4n ± 2%   418.1n ± 2%  -13.33% (p=0.002 n=6)
PluginFilter/noop/params:_real-12                         482.6n ± 0%   427.0n ± 2%  -11.52% (p=0.002 n=6)
PluginFilter/test/params:_small-12                        7.895µ ± 1%   7.860µ ± 0%        ~ (p=0.225 n=6)
PluginFilter/test/params:_real-12                         115.5µ ± 1%   114.3µ ± 2%        ~ (p=0.071 n=6)
PluginScore/noop-wat/params:_small-12                     269.4n ± 0%   269.7n ± 1%        ~ (p=0.913 n=6)
PluginScore/noop-wat/params:_real-12                      270.0n ± 0%   269.8n ± 0%        ~ (p=1.000 n=6)
PluginScore/noop/params:_small-12                         538.8n ± 0%   519.4n ± 0%   -3.61% (p=0.002 n=6)
PluginScore/noop/params:_real-12                          493.4n ± 1%   465.0n ± 1%   -5.76% (p=0.002 n=6)
PluginScore/test/params:_small-12                         4.551µ ± 1%   4.720µ ± 1%   +3.71% (p=0.002 n=6)
PluginScore/test/params:_real-12                          48.48µ ± 1%   49.24µ ± 2%   +1.58% (p=0.004 n=6)
PluginPrefilterFilterAndScore/noop-wat/params:_small-12   401.0n ± 0%   412.8n ± 3%   +2.93% (p=0.002 n=6)
PluginPrefilterFilterAndScore/noop-wat/params:_real-12    401.4n ± 0%   402.4n ± 1%        ~ (p=0.288 n=6)
PluginPrefilterFilterAndScore/noop/params:_small-12       720.5n ± 2%   652.2n ± 1%   -9.49% (p=0.002 n=6)
PluginPrefilterFilterAndScore/noop/params:_real-12        746.7n ± 3%   674.3n ± 2%   -9.69% (p=0.002 n=6)
PluginPrefilterFilterAndScore/test/params:_small-12       9.188µ ± 1%   8.510µ ± 1%   -7.38% (p=0.002 n=6)
PluginPrefilterFilterAndScore/test/params:_real-12        118.2µ ± 2%   110.2µ ± 2%   -6.76% (p=0.002 n=6)
geomean                                                   1.374µ        1.330µ        -3.18%
codefromthecrypt commented 10 months ago

sorry I will fix the tinygo test.

codefromthecrypt commented 10 months ago

yeah can't test panics with tinygo+wasm yet. I'll change accordingly https://github.com/tinygo-org/tinygo/issues/2914

codefromthecrypt commented 10 months ago

tests pass re-running benchmark as I had to change the tinygo impl a bit

codefromthecrypt commented 10 months ago

bench is still a lot better. PTAL!

sanposhiho commented 10 months ago

Whoops, I submited the review in a middle. Wait a min for the full review.

k8s-ci-robot commented 10 months ago

[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: - ~~[OWNERS](https://github.com/kubernetes-sigs/kube-scheduler-wasm-extension/blob/main/OWNERS)~~ [codefromthecrypt,sanposhiho] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment