Skip to content

Commit c1f2213

Browse files
committed
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 <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Trust: Michael Pratt <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent fe75fe3 commit c1f2213

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

src/runtime/pprof/pprof_norusage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !darwin && !linux
5+
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
66

77
package pprof
88

src/runtime/pprof/pprof_rusage.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build darwin || linux
5+
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
66

77
package pprof
88

@@ -17,10 +17,12 @@ import (
1717
func addMaxRSS(w io.Writer) {
1818
var rssToBytes uintptr
1919
switch runtime.GOOS {
20-
case "linux", "android":
20+
case "aix", "android", "dragonfly", "freebsd", "linux", "netbsd", "openbsd":
2121
rssToBytes = 1024
2222
case "darwin", "ios":
2323
rssToBytes = 1
24+
case "illumos", "solaris":
25+
rssToBytes = uintptr(syscall.Getpagesize())
2426
default:
2527
panic("unsupported OS")
2628
}

src/runtime/pprof/rusage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build darwin || freebsd || linux || netbsd || openbsd
5+
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
66

77
package pprof
88

src/syscall/syscall_aix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ func PtraceDetach(pid int) (err error) { return ptrace64(PT_DETACH, int64(pid),
594594
//sys Getppid() (ppid int)
595595
//sys Getpriority(which int, who int) (n int, err error)
596596
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
597+
//sysnb Getrusage(who int, rusage *Rusage) (err error)
597598
//sysnb Getuid() (uid int)
598599
//sys Kill(pid int, signum Signal) (err error)
599600
//sys Lchown(path string, uid int, gid int) (err error)

src/syscall/syscall_solaris.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i
421421
//sys Getppid() (ppid int)
422422
//sys Getpriority(which int, who int) (n int, err error)
423423
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
424+
//sysnb Getrusage(who int, rusage *Rusage) (err error)
424425
//sysnb Gettimeofday(tv *Timeval) (err error)
425426
//sysnb Getuid() (uid int)
426427
//sys Kill(pid int, signum Signal) (err error)

src/syscall/zsyscall_aix_ppc64.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/syscall/zsyscall_solaris_amd64.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)