Skip to content

Instantly share code, notes, and snippets.

@dobegor
Created September 24, 2020 13:27
Show Gist options
  • Save dobegor/01144abe5a53fcafadacc69cde44fb59 to your computer and use it in GitHub Desktop.
Save dobegor/01144abe5a53fcafadacc69cde44fb59 to your computer and use it in GitHub Desktop.
(pprof) top
Showing nodes accounting for 50230ms, 67.43% of 74490ms total
Dropped 1185 nodes (cum <= 372.45ms)
Showing top 10 nodes out of 221
flat flat% sum% cum cum%
34160ms 45.86% 45.86% 34380ms 46.15% runtime.adjusttimers
3950ms 5.30% 51.16% 4120ms 5.53% syscall.Syscall
2870ms 3.85% 55.01% 2990ms 4.01% runtime.findObject
2720ms 3.65% 58.67% 6710ms 9.01% runtime.scanobject
1600ms 2.15% 60.81% 2520ms 3.38% math/big.nat.divBasic
1150ms 1.54% 62.36% 11040ms 14.82% runtime.mallocgc
990ms 1.33% 63.69% 990ms 1.33% runtime.osyield
950ms 1.28% 64.96% 950ms 1.28% runtime.markBits.isMarked (inline)
940ms 1.26% 66.22% 940ms 1.26% runtime.memclrNoHeapPointers
900ms 1.21% 67.43% 1930ms 2.59% compress/flate.(*compressor).deflate
(pprof) list runtime.adjusttimers
Total: 1.24mins
ROUTINE ======================== runtime.adjusttimers in runtime/time.go
34.16s 34.38s (flat, cum) 46.15% of Total
. . 647: }
. . 648: return
. . 649: }
. . 650: var moved []*timer
. . 651:loop:
540ms 540ms 652: for i := 0; i < len(pp.timers); i++ {
160ms 160ms 653: t := pp.timers[i]
24.67s 24.67s 654: if t.pp.ptr() != pp {
. . 655: throw("adjusttimers: bad p")
. . 656: }
8.44s 8.44s 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:
10ms 10ms 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.
. 120ms 676: dodeltimer(pp, i)
200ms 290ms 677: moved = append(moved, t)
. . 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: }
140ms 140ms 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 {
. 10ms 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