From c1f22134f22158ebeebf450357f711eb22fab202 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 10 Mar 2022 09:28:09 +0100 Subject: runtime/pprof, syscall: report MaxRSS on all unix platforms All unix platforms currently supported by Go provide the getrusage syscall. On aix and solaris the Getrusage syscall wrapper is not available yet, so add and use it to report MaxRSS in memory profiles. Change-Id: Ie880a3058171031fd2e12ccf9adfb85ce18858b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/391434 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Trust: Michael Pratt Reviewed-by: Ian Lance Taylor --- src/runtime/pprof/pprof_norusage.go | 2 +- src/runtime/pprof/pprof_rusage.go | 6 ++++-- src/runtime/pprof/rusage_test.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/runtime/pprof') diff --git a/src/runtime/pprof/pprof_norusage.go b/src/runtime/pprof/pprof_norusage.go index cbc5176cfa..3d6052519c 100644 --- a/src/runtime/pprof/pprof_norusage.go +++ b/src/runtime/pprof/pprof_norusage.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !darwin && !linux +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris package pprof diff --git a/src/runtime/pprof/pprof_rusage.go b/src/runtime/pprof/pprof_rusage.go index 46263fedd9..7df81eca23 100644 --- a/src/runtime/pprof/pprof_rusage.go +++ b/src/runtime/pprof/pprof_rusage.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || linux +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris package pprof @@ -17,10 +17,12 @@ import ( func addMaxRSS(w io.Writer) { var rssToBytes uintptr switch runtime.GOOS { - case "linux", "android": + case "aix", "android", "dragonfly", "freebsd", "linux", "netbsd", "openbsd": rssToBytes = 1024 case "darwin", "ios": rssToBytes = 1 + case "illumos", "solaris": + rssToBytes = uintptr(syscall.Getpagesize()) default: panic("unsupported OS") } diff --git a/src/runtime/pprof/rusage_test.go b/src/runtime/pprof/rusage_test.go index b0d651e0eb..f274d0caa3 100644 --- a/src/runtime/pprof/rusage_test.go +++ b/src/runtime/pprof/rusage_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || freebsd || linux || netbsd || openbsd +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris package pprof -- cgit v1.3-5-g9baa