kubernetes-sigs / kube-scheduler-wasm-extension

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

Implement PreScore and change NodeNumberPlugin to use it #59

Closed codefromthecrypt closed 9 months ago

codefromthecrypt commented 9 months ago

What type of PR is this?

/kind feature

What this PR does / why we need it:

This implement PreScore and changes NodeNumberPlugin to use it.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

Almost done: I need to do a review pass tomorrow.

Does this PR introduce a user-facing change?

NONE

What are the benchmark results of this change?

Performance is slightly slower because we always call prefilter. So, when we move logic to prescore, there's an additional host call roundtrip.

goos: darwin
goarch: arm64
pkg: sigs.k8s.io/kube-scheduler-wasm-extension/internal/e2e
                          │ before.txt  │              now.txt              │
                          │   sec/op    │   sec/op     vs base              │
Example_NodeNumber/New-12   63.43m ± 4%   64.32m ± 1%       ~ (p=0.394 n=6)
Example_NodeNumber/Run-12   51.34µ ± 2%   51.88µ ± 2%       ~ (p=0.058 n=6)
geomean                     1.805m        1.827m       +1.23%
codefromthecrypt commented 9 months ago

ok almost done.

I completed PreScore and ported the node number example from the scheduler simulator and also unit tested it. I cleared the test code out of the examples directory so that the only thing there is more realistic.

Tomorrow, I will look for any missing tests and polish for review.

codefromthecrypt commented 9 months ago

going with this first to keep PreScore change simple https://github.com/kubernetes-sigs/kube-scheduler-wasm-extension/pull/60

codefromthecrypt commented 9 months ago

ok once this is in, I'll implement configuration to make our NodeNumberPlugin more realistic.

codefromthecrypt commented 9 months ago

What's needed after this is a config ABI similar to http-wasm. I'll add links on that for someone to follow-up on:

https://http-wasm.io/http-handler-abi/#get_config https://github.com/http-wasm/http-wasm-guest-tinygo/blob/27f49b76b63759ad5694e32545dba595cd5fe9db/handler/host.go#L22-L25 https://github.com/http-wasm/http-wasm-guest-tinygo/blob/27f49b76b63759ad5694e32545dba595cd5fe9db/handler/internal/imports/imports.go#L10-L11 https://github.com/http-wasm/http-wasm-host-go/blob/990427a52ee421643c21142d462304c91415932b/handler/middleware.go#L251-L258 https://github.com/http-wasm/http-wasm-host-go/blob/990427a52ee421643c21142d462304c91415932b/handler/options.go#L25-L30

This would be used to complete the NodeNumberPlugin and would work if the config can be read inside the wasm guest, assigned by the host.

k8s-ci-robot commented 9 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