Skip to content

runtime: timer doesn't scale on multi-CPU systems with a lot of timers #15133

@valyala

Description

@valyala

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +dfad3f8 Tue Apr 5 16:10:33 2016 +0300 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build040466407=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

I run an http server serving more than a million concurrent TCP keep-alive connections on a system with 32 CPU cores. Each connection has read and write deadlines set via net.Conn.SetReadDeadline and net.Conn.SetWriteDeadline.

What did you expect to see?

Server performance should scale with GOMAXPROCS up to the number of CPU cores.

What did you see instead?

  • addtimer and deltimer functions from runtime/time.go are at the top of CPU profile.
  • iowait reaches 20% due to memory ping-pong across CPU cores inside siftupTimer and siftdownTimer functions in runtime/time.go.

@dvyukov , could you look into this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions