Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(171)

Side by Side Diff: src/pkg/runtime/debug/garbage.go

Issue 160200044: [dev.power64] code review 160200044: build: merge default into dev.power64 (Closed)
Patch Set: diff -r be0c14f62257b42485019e9e1db23cf40d2e249f https://code.google.com/p/go Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/debug.go ('k') | src/pkg/runtime/debug/stubs.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package debug 5 package debug
6 6
7 import ( 7 import (
8 "runtime" 8 "runtime"
9 "sort" 9 "sort"
10 "time" 10 "time"
11 ) 11 )
12 12
13 // GCStats collect information about recent garbage collections. 13 // GCStats collect information about recent garbage collections.
14 type GCStats struct { 14 type GCStats struct {
15 LastGC time.Time // time of last collection 15 LastGC time.Time // time of last collection
16 NumGC int64 // number of garbage collections 16 NumGC int64 // number of garbage collections
17 PauseTotal time.Duration // total pause for all collections 17 PauseTotal time.Duration // total pause for all collections
18 Pause []time.Duration // pause history, most recent first 18 Pause []time.Duration // pause history, most recent first
19 PauseQuantiles []time.Duration 19 PauseQuantiles []time.Duration
20 } 20 }
21 21
22 // Implemented in package runtime.
23 func readGCStats(*[]time.Duration)
24 func enableGC(bool) bool
25 func setGCPercent(int) int
26 func freeOSMemory()
27 func setMaxStack(int) int
28 func setMaxThreads(int) int
29
30 // ReadGCStats reads statistics about garbage collection into stats. 22 // ReadGCStats reads statistics about garbage collection into stats.
31 // The number of entries in the pause history is system-dependent; 23 // The number of entries in the pause history is system-dependent;
32 // stats.Pause slice will be reused if large enough, reallocated otherwise. 24 // stats.Pause slice will be reused if large enough, reallocated otherwise.
33 // ReadGCStats may use the full capacity of the stats.Pause slice. 25 // ReadGCStats may use the full capacity of the stats.Pause slice.
34 // If stats.PauseQuantiles is non-empty, ReadGCStats fills it with quantiles 26 // If stats.PauseQuantiles is non-empty, ReadGCStats fills it with quantiles
35 // summarizing the distribution of pause time. For example, if 27 // summarizing the distribution of pause time. For example, if
36 // len(stats.PauseQuantiles) is 5, it will be filled with the minimum, 28 // len(stats.PauseQuantiles) is 5, it will be filled with the minimum,
37 // 25%, 50%, 75%, and maximum pause times. 29 // 25%, 50%, 75%, and maximum pause times.
38 func ReadGCStats(stats *GCStats) { 30 func ReadGCStats(stats *GCStats) {
39 // Create a buffer with space for at least two copies of the 31 // Create a buffer with space for at least two copies of the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 func (x byDuration) Less(i, j int) bool { return x[i] < x[j] } 76 func (x byDuration) Less(i, j int) bool { return x[i] < x[j] }
85 77
86 // SetGCPercent sets the garbage collection target percentage: 78 // SetGCPercent sets the garbage collection target percentage:
87 // a collection is triggered when the ratio of freshly allocated data 79 // a collection is triggered when the ratio of freshly allocated data
88 // to live data remaining after the previous collection reaches this percentage. 80 // to live data remaining after the previous collection reaches this percentage.
89 // SetGCPercent returns the previous setting. 81 // SetGCPercent returns the previous setting.
90 // The initial setting is the value of the GOGC environment variable 82 // The initial setting is the value of the GOGC environment variable
91 // at startup, or 100 if the variable is not set. 83 // at startup, or 100 if the variable is not set.
92 // A negative percentage disables garbage collection. 84 // A negative percentage disables garbage collection.
93 func SetGCPercent(percent int) int { 85 func SetGCPercent(percent int) int {
94 » old := setGCPercent(percent) 86 » old := setGCPercent(int32(percent))
95 runtime.GC() 87 runtime.GC()
96 » return old 88 » return int(old)
97 } 89 }
98 90
99 // FreeOSMemory forces a garbage collection followed by an 91 // FreeOSMemory forces a garbage collection followed by an
100 // attempt to return as much memory to the operating system 92 // attempt to return as much memory to the operating system
101 // as possible. (Even if this is not called, the runtime gradually 93 // as possible. (Even if this is not called, the runtime gradually
102 // returns memory to the operating system in a background task.) 94 // returns memory to the operating system in a background task.)
103 func FreeOSMemory() { 95 func FreeOSMemory() {
104 freeOSMemory() 96 freeOSMemory()
105 } 97 }
106 98
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 130
139 // SetPanicOnFault controls the runtime's behavior when a program faults 131 // SetPanicOnFault controls the runtime's behavior when a program faults
140 // at an unexpected (non-nil) address. Such faults are typically caused by 132 // at an unexpected (non-nil) address. Such faults are typically caused by
141 // bugs such as runtime memory corruption, so the default response is to crash 133 // bugs such as runtime memory corruption, so the default response is to crash
142 // the program. Programs working with memory-mapped files or unsafe 134 // the program. Programs working with memory-mapped files or unsafe
143 // manipulation of memory may cause faults at non-nil addresses in less 135 // manipulation of memory may cause faults at non-nil addresses in less
144 // dramatic situations; SetPanicOnFault allows such programs to request 136 // dramatic situations; SetPanicOnFault allows such programs to request
145 // that the runtime trigger only a panic, not a crash. 137 // that the runtime trigger only a panic, not a crash.
146 // SetPanicOnFault applies only to the current goroutine. 138 // SetPanicOnFault applies only to the current goroutine.
147 // It returns the previous setting. 139 // It returns the previous setting.
148 func SetPanicOnFault(enabled bool) bool 140 func SetPanicOnFault(enabled bool) bool {
141 » return setPanicOnFault(enabled)
142 }
149 143
150 // WriteHeapDump writes a description of the heap and the objects in 144 // WriteHeapDump writes a description of the heap and the objects in
151 // it to the given file descriptor. 145 // it to the given file descriptor.
152 // The heap dump format is defined at http://golang.org/s/go13heapdump. 146 // The heap dump format is defined at http://golang.org/s/go13heapdump.
153 func WriteHeapDump(fd uintptr) 147 func WriteHeapDump(fd uintptr)
OLDNEW
« no previous file with comments | « src/pkg/runtime/debug.go ('k') | src/pkg/runtime/debug/stubs.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b