Skip to content
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

fix(scheduler): remove the defer function cost #82330

Conversation

draveness
Copy link
Contributor

@draveness draveness commented Sep 4, 2019

/kind bug
/sig scheduling
/priority important-longterm

What this PR does / why we need it:

Remove the cost of the defer function in the scheduler perf test.

Without StopTimer

package main

import "testing"
import "time"

func test() {
	 // ...
}

func BenchmarkWithoutStopTimer(b *testing.B) {
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		test()
	}

	defer time.Sleep(1 * time.Second)
}

$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/golang
BenchmarkLocality-8   	       1	1001293479 ns/op
PASS
ok  	github.com/golang	1.010s
(base)

With StopTimer

package main

import "testing"
import "time"

func test() {
	 // ...
}

func BenchmarkLocality(b *testing.B) {
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
	    test()
	}

	defer time.Sleep(1 * time.Second)
	b.StopTimer()
}

$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/golang
BenchmarkLocality-8   	   30000	     45513 ns/op
PASS
ok  	github.com/golang	5.866s
(base)

Which issue(s) this PR fixes:

ref: #81719

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Sep 4, 2019
@draveness draveness mentioned this pull request Sep 4, 2019
5 tasks
@draveness
Copy link
Contributor Author

/assign @Huang-Wei @ahg-g

@@ -409,6 +409,7 @@ func benchmarkScheduling(numNodes, numExistingPods, minPods int,
// Since the total amount of time is relatively large, it might not be a concern.
time.Sleep(100 * time.Millisecond)
}
b.StopTimer()
Copy link
Member

@Huang-Wei Huang-Wei Sep 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's put a comment explaining that without this line we're taking the overhead of defer() into account.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @draveness
Agree with @Huang-Wei . For readability, it is necessary to note why this line was added :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, PTAL

@draveness draveness force-pushed the feature/remove-additional-cost-in-the-scheduler-benchmark branch from 8168c6b to 4105fea Compare September 5, 2019 02:57
Copy link
Member

@SataQiu SataQiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 @draveness
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 5, 2019
@ahg-g
Copy link
Member

ahg-g commented Sep 5, 2019

/lgtm

@draveness
Copy link
Contributor Author

/retest

@Huang-Wei
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: draveness, Huang-Wei, SataQiu

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2019
@k8s-ci-robot k8s-ci-robot merged commit 3b393e3 into kubernetes:master Sep 11, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants