]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid string allocation in printDebuglog
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 2 Jun 2022 21:10:26 +0000 (21:10 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 3 Jun 2022 20:16:21 +0000 (20:16 +0000)
Either due to a new nowritebarrierrec annotation or a change in escape
analysis, printDebuglog can't be called from sighandler anymore.

Fix this by avoiding a string allocation that's the primary culprit.

Change-Id: Ic84873a453f45852b0443a46597ed3ab8c9443fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/410121
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/debuglog.go

index 7f92a6baf8650b68e6f229dcd4a967d6ef41c326..ca1a791c93f748d9b8a64f9db94056e7388fbfc8 100644 (file)
@@ -777,7 +777,8 @@ func printDebugLog() {
                        // Logged before runtimeInitTime was set.
                        pnano = 0
                }
-               print(string(itoaDiv(tmpbuf[:], uint64(pnano), 9)))
+               pnanoBytes := itoaDiv(tmpbuf[:], uint64(pnano), 9)
+               print(slicebytetostringtmp((*byte)(noescape(unsafe.Pointer(&pnanoBytes[0]))), len(pnanoBytes)))
                print(" P ", p, "] ")
 
                for i := 0; s.begin < s.end; i++ {