Skip to content

Instantly share code, notes, and snippets.

@dobegor
Created September 24, 2020 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dobegor/80134e0d4d997cf03fa8f429da72d753 to your computer and use it in GitHub Desktop.
Save dobegor/80134e0d4d997cf03fa8f429da72d753 to your computer and use it in GitHub Desktop.
(pprof) top
Showing nodes accounting for 42.46s, 56.69% of 74.90s total
Dropped 1318 nodes (cum <= 0.37s)
Showing top 10 nodes out of 258
flat flat% sum% cum cum%
20.63s 27.54% 27.54% 20.83s 27.81% runtime.adjusttimers
4.59s 6.13% 33.67% 4.73s 6.32% runtime.timeSleepUntil
4.22s 5.63% 39.31% 4.44s 5.93% syscall.Syscall
3.11s 4.15% 43.46% 4.85s 6.48% math/big.nat.divBasic
2.65s 3.54% 47.00% 6.39s 8.53% runtime.scanobject
2.51s 3.35% 50.35% 2.65s 3.54% runtime.findObject
1.36s 1.82% 52.16% 12.23s 16.33% runtime.mallocgc
1.16s 1.55% 53.71% 1.16s 1.55% runtime.osyield
1.15s 1.54% 55.25% 1.15s 1.54% runtime.memclrNoHeapPointers
1.08s 1.44% 56.69% 1.08s 1.44% math/big.addMulVVW
(pprof) list runtime.adjusttimers
Total: 1.25mins
ROUTINE ======================== runtime.adjusttimers in runtime/time.go
20.63s 20.83s (flat, cum) 27.81% of Total
. . 647: }
. . 648: return
. . 649: }
. . 650: var moved []*timer
. . 651:loop:
380ms 380ms 652: for i := 0; i < len(pp.timers); i++ {
140ms 140ms 653: t := pp.timers[i]
14.59s 14.59s 654: if t.pp.ptr() != pp {
. . 655: throw("adjusttimers: bad p")
. . 656: }
5.23s 5.23s 657: switch s := atomic.Load(&t.status); s {
. . 658: case timerDeleted:
. . 659: if atomic.Cas(&t.status, s, timerRemoving) {
. . 660: dodeltimer(pp, i)
. . 661: if !atomic.Cas(&t.status, timerRemoving, timerRemoved) {
. . 662: badTimer()
. . 663: }
. . 664: atomic.Xadd(&pp.deletedTimers, -1)
. . 665: // Look at this heap position again.
. . 666: i--
. . 667: }
. . 668: case timerModifiedEarlier, timerModifiedLater:
. . 669: if atomic.Cas(&t.status, s, timerMoving) {
. . 670: // Now we can change the when field.
. . 671: t.when = t.nextwhen
. . 672: // Take t off the heap, and hold onto it.
. . 673: // We don't add it back yet because the
. . 674: // heap manipulation could cause our
. . 675: // loop to skip some other timer.
. 90ms 676: dodeltimer(pp, i)
220ms 310ms 677: moved = append(moved, t)
10ms 10ms 678: if s == timerModifiedEarlier {
. . 679: if n := atomic.Xadd(&pp.adjustTimers, -1); int32(n) <= 0 {
. . 680: break loop
. . 681: }
. . 682: }
. . 683: // Look at this heap position again.
. . 684: i--
. . 685: }
60ms 60ms 686: case timerNoStatus, timerRunning, timerRemoving, timerRemoved, timerMoving:
. . 687: badTimer()
. . 688: case timerWaiting:
. . 689: // OK, nothing to do.
. . 690: case timerModifying:
. . 691: // Check again after modification is complete.
. . 692: osyield()
. . 693: i--
. . 694: default:
. . 695: badTimer()
. . 696: }
. . 697: }
. . 698:
. . 699: if len(moved) > 0 {
. 20ms 700: addAdjustedTimers(pp, moved)
. . 701: }
. . 702:
. . 703: if verifyTimers {
. . 704: verifyTimerHeap(pp)
. . 705: }
(pprof)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment