Skip to content

Commit 7caa174

Browse files
authored
Clarify heap profile trigger (#851)
The heap profile is triggered when total heap allocated (inuse + garbage objects) passes a certain threshold. However, the profiles are mainly useful for looking at `inuse_space`. This PR improves the docs to make this a tiny bit less confusing.
1 parent bfd8ee8 commit 7caa174

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

build/builder.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ type Options struct {
119119
// Sourcegraph specific option.
120120
ShardMerging bool
121121

122-
// HeapProfileTriggerBytes is the heap usage in bytes that will trigger a memory profile. If 0, no memory profile will be triggered.
122+
// HeapProfileTriggerBytes is the heap allocation in bytes that will trigger a memory profile. If 0, no memory profile
123+
// will be triggered. Note this trigger looks at total heap allocation (which includes both inuse and garbage objects).
124+
//
123125
// Profiles will be written to files named `index-memory.prof.n` in the index directory. No more than 10 files are written.
124126
//
125127
// Note: heap checking is "best effort", and it's possible for the process to OOM without triggering the heap profile.
@@ -1023,7 +1025,7 @@ func (b *Builder) CheckMemoryUsage() {
10231025
if m.HeapAlloc > b.opts.HeapProfileTriggerBytes && b.heapProfileMu.TryLock() {
10241026
defer b.heapProfileMu.Unlock()
10251027

1026-
log.Printf("writing memory profile, heap usage: %s", humanize.Bytes(m.HeapAlloc))
1028+
log.Printf("writing memory profile, allocated heap: %s", humanize.Bytes(m.HeapAlloc))
10271029
name := filepath.Join(b.opts.IndexDir, fmt.Sprintf("indexmemory.prof.%d", b.heapProfileNum))
10281030
f, err := os.Create(name)
10291031
if err != nil {

0 commit comments

Comments
 (0)