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

Implements prefilter and configures TinyGo unit tests #43

Closed codefromthecrypt closed 11 months ago

codefromthecrypt commented 11 months ago

What type of PR is this?

/kind feature

What this PR does / why we need it:

This implements the prefilter function and configures TinyGo unit tests via make test-guest. This runs the same unit tests without TinyGo on make test.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

What are the benchmark results of this change?

goos: darwin
goarch: arm64
pkg: sigs.k8s.io/kube-scheduler-wasm-extension/internal/e2e
                                                        │  before.txt  │              after.txt               │
                                                        │    sec/op    │    sec/op     vs base                │
PluginFilter/noop-wat/params:_small-12                    262.3n ±  2%   265.2n ±  1%       ~ (p=0.121 n=6)
PluginFilter/noop-wat/params:_real-12                     269.6n ±  2%   268.3n ±  1%       ~ (p=0.619 n=6)
PluginFilter/noop/params:_small-12                        333.1n ±  1%   328.0n ±  1%  -1.52% (p=0.002 n=6)
PluginFilter/noop/params:_real-12                         338.0n ±  2%   332.1n ±  3%  -1.75% (p=0.004 n=6)
PluginFilter/test/params:_small-12                        6.431µ ±  1%   6.438µ ±  0%       ~ (p=0.669 n=6)
PluginFilter/test/params:_real-12                         115.5µ ±  2%   116.8µ ±  0%  +1.14% (p=0.004 n=6)
PluginScore/noop-wat/params:_small-12                     260.6n ±  0%   259.7n ±  3%       ~ (p=0.056 n=6)
PluginScore/noop-wat/params:_real-12                      265.4n ±  0%   263.9n ±  0%  -0.55% (p=0.004 n=6)
PluginScore/noop/params:_small-12                         382.4n ±  1%   378.1n ±  0%  -1.15% (p=0.002 n=6)
PluginScore/noop/params:_real-12                          354.4n ±  0%   348.1n ±  0%  -1.76% (p=0.002 n=6)
PluginScore/test/params:_small-12                         3.668µ ±  1%   3.639µ ±  1%  -0.79% (p=0.002 n=6)
PluginScore/test/params:_real-12                          39.85µ ±  2%   39.16µ ± 12%       ~ (p=0.065 n=6)
PluginFilterAndScore/noop-wat/params:_small-12            379.8n ±  0%
PluginFilterAndScore/noop-wat/params:_real-12             390.6n ± 16%
PluginFilterAndScore/noop/params:_small-12                586.5n ±  5%
PluginFilterAndScore/noop/params:_real-12                 554.6n ±  6%
PluginFilterAndScore/test/params:_small-12                10.17µ ±  1%
PluginFilterAndScore/test/params:_real-12                 169.5µ ±  4%
PluginPreFilter/noop-wat/params:_small-12                                281.1n ±  3%
PluginPreFilter/noop-wat/params:_real-12                                 289.1n ±  1%
PluginPreFilter/noop/params:_small-12                                    347.2n ±  1%
PluginPreFilter/noop/params:_real-12                                     350.6n ±  0%
PluginPreFilter/test/params:_small-12                                    3.533µ ±  2%
PluginPreFilter/test/params:_real-12                                     40.56µ ±  9%
PluginPrefilterFilterAndScore/noop-wat/params:_small-12                  517.5n ±  1%
PluginPrefilterFilterAndScore/noop-wat/params:_real-12                   524.3n ±  3%
PluginPrefilterFilterAndScore/noop/params:_small-12                      788.3n ±  0%
PluginPrefilterFilterAndScore/noop/params:_real-12                       753.4n ±  0%
PluginPrefilterFilterAndScore/test/params:_small-12                      14.10µ ±  1%
PluginPrefilterFilterAndScore/test/params:_real-12                       218.8µ ±  1%
geomean                                                   1.436µ         1.429µ        -0.65%               ¹
codefromthecrypt commented 11 months ago

just noticed the prefilter example was almost 1MB of wasm. trying to figure out why, and reduce it.

codefromthecrypt commented 11 months ago

I forgot that our baseline size is pretty big (first nottinygc and then tinygo 0.28 is also larger).

Anyway, I was able to make it the same size as score.

$ du -k  examples/*/main.wasm
996 examples/filter-simple/main.wasm
960 examples/prefilter-simple/main.wasm
960 examples/score-simple/main.wasm
codefromthecrypt commented 11 months ago

fixed bench, as the prior commit didn't actually call prefilter. The below is higher because we don't yet cache the pod being scheduled. The next PR should show some dramatic difference

PluginFilterAndScore/test/params:_real-12                     169.5µ ±  4%
PluginPrefilterFilterAndScore/test/params:_real-12            218.8µ ±  1%
k8s-ci-robot commented 11 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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: - ~~[OWNERS](https://github.com/kubernetes-sigs/kube-scheduler-wasm-extension/blob/main/OWNERS)~~ [kerthcet] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
sanposhiho commented 11 months ago

/lgtm