Skip to content

time: time.Timer with large duration causes 100% CPU usage on Intel 32-bit #5063

@kisielk

Description

@kisielk
What steps will reproduce the problem?
http://play.golang.org/p/wpNOzCVSr9

What is the expected output?
Idle CPU

What do you see instead?
In the output of top the process has 100% CPU usage.

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Ubuntu 12.04

Which version are you using?  (run 'go version')
go version devel +b5b5c246be0c Fri Mar 15 17:08:07 2013 -0700 linux/386

If the divisor is changed to 1.44 or larger, the process does not use 100% CPU.

Here's a profile from a slightly different program that was waiting on such a timer:

(pprof) top
Total: 80 samples
      25  31.2%  31.2%       37  46.2% runtime.entersyscallblock
      15  18.8%  50.0%       76  95.0% timerproc
      10  12.5%  62.5%       10  12.5% releasep
       8  10.0%  72.5%        8  10.0% runtime.nanotime
       6   7.5%  80.0%        6   7.5% runtime.noteclear
       5   6.2%  86.2%        5   6.2% runtime.xchg
       4   5.0%  91.2%        9  11.2% runtime.lock
       3   3.8%  95.0%        3   3.8% runtime.setprof
       1   1.2%  96.2%        1   1.2% runtime.exitsyscall
       1   1.2%  97.5%        1   1.2% runtime.getcallersp

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions