]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: print pp.schedtick in scheddetail even when !detailed
authorNicolas Hillegeer <aktau@google.com>
Thu, 12 Dec 2024 16:49:03 +0000 (08:49 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 18 Feb 2025 16:13:49 +0000 (08:13 -0800)
Provides, on one line, an approximation of P scheduling throughput: how
many times execute() was called for a given P. Said another way: how
many RUNNABLE to RUNNING transitions have happened for this P.

This allows discerning whether a P actually did anything, and how it
compares to other periods of a processes operation.

This should be useful to analyze (kernel) scheduler hiccups.

Investigators will want to subtract the tick values from subsequent
schedtrace lines to get a rate of schedulings. I've opted to add a space
around the first and last element as well to make it more uniform to do
the proposed subtracting with tools like AWK.

Change-Id: I69d6dae1509ad285d43799f38bcaa3aa0fb2352e
Reviewed-on: https://go-review.googlesource.com/c/go/+/635636
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Nicolas Hillegeer <aktau@google.com>

src/runtime/proc.go

index c9d04edd07fe20215360c09c9c4750533030d83c..98e135ff2ad108630c71db77fcb6119238fbb700 100644 (file)
@@ -6404,18 +6404,28 @@ func schedtrace(detailed bool) {
                        print(" runqsize=", t-h, " gfreecnt=", pp.gFree.n, " timerslen=", len(pp.timers.heap), "\n")
                } else {
                        // In non-detailed mode format lengths of per-P run queues as:
-                       // [len1 len2 len3 len4]
+                       // [ len1 len2 len3 len4 ]
                        print(" ")
                        if i == 0 {
-                               print("[")
+                               print("[ ")
                        }
                        print(t - h)
                        if i == len(allp)-1 {
-                               print("]\n")
+                               print(" ]")
                        }
                }
        }
 
+       if !detailed {
+               // Format per-P schedticks as: schedticks=[ tick1 tick2 tick3 tick4 ].
+               print(" schedticks=[ ")
+               for _, pp := range allp {
+                       print(pp.schedtick)
+                       print(" ")
+               }
+               print("]\n")
+       }
+
        if !detailed {
                unlock(&sched.lock)
                return