Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify heap profile trigger #851

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ type Options struct {
// Sourcegraph specific option.
ShardMerging bool

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

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