/ go Public
runtime: network read using a lot of CPU #52341
Issues related to the Go compiler and/or runtime.
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
Does this issue reproduce with the latest release?
Yes. This issue is more of a feature request than a bug fix.
What operating system and processor architecture are you using (
What did you do?
My code is running a tcp server and read from connection in a for loop
The problem is the syscall.read is 50% of the total CPU, see the profiling below
Looking at https://github.com/golang/go/blob/master/src/internal/poll/fd_unix.go#L163-L167
My theory is that on line 163 it calls syscall.read to read the socket, and syscall.read returns error when there is nothing to read. Then on line 167 it calls fd.pd.waitRead() to wait for data. And when data arrives at the connection, the fd is notified and continue to read. I'm seeing two problems here,
The text was updated successfully, but these errors were encountered: