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
runtime: unnecessary return in netpoll #49026
Comments
Change https://golang.org/cl/356253 mentions this issue: |
Could you explain more about why the return is unnecessary and why "[it] should appear every 50 ms"? What specific problem in real programs does it cause? Thanks. |
“unnecessary” means that when the function netpoll return, there is no goroutine to run, no timer to run and the epollwait is not broken by "netpollbreak". This situation occurs when the epollwait is broken by network data, but there is no goroutine is blocking on it, like the main funtion in server.go above. It sleep 50ms, then read some data from socket in the loop. If the data reached when it is sleeping, the epollwait will be broken and will return from netpoll. Then it will block on epollwait again. This return is unnecessary.
The main goroutine invoke
This issue is about performance. Reducing the unnecessary return can reduce CPU usage. |
how is this measured? - is there a way to test this? |
I did a comparison test. Test environment:# go version
go version go1.17.2 linux/amd64
|
@cherrymui @harshavardhana |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
server.go:
client.go
And excute these command:
What did you expect to see?
In trace view, the event "proc start" and "proc stop" should appear every 50 ms because of
time.Sleep(50 * time.Millisecond)
.What did you see instead?
The event "proc start" and "proc stop" appears every 1 ms because of client sends data every 1 ms.


The text was updated successfully, but these errors were encountered: