Skip to content

when GOMEMLIMIT is set, write profiles#8743

Draft
jsha wants to merge 1 commit intomainfrom
dump-heap
Draft

when GOMEMLIMIT is set, write profiles#8743
jsha wants to merge 1 commit intomainfrom
dump-heap

Conversation

@jsha
Copy link
Copy Markdown
Contributor

@jsha jsha commented May 1, 2026

We've been observing spikes in memory usage in the WFE. To track them down, we'd like to automatically trigger writing profiles to disk when memory usage is high.

This is controlled by two environment variables:

  • If $GOMEMLIMIT is unset, the profile dumping does not happen. This value is also used by the Go runtime to set a soft limit, and we intend to set it to something below where the OS will kill the process. https://pkg.go.dev/runtime#hdr-Environment_Variables
  • Files are written with os.CreateTemp(), so their location can be controlled with $TMPDIR.

Draft to seek feedback about logging. The current version gets run from cmd/boulder/main.go, before a logger is built. It uses fmt.Println() for errors. To use a real logger, we'd need to make memoryMonitor() exported and call it from each of the Boulder components after their config is parsed and the logger is built. Thoughts?

We've been observing spikes in memory usage in the WFE. To track them down, we'd
like to automatically trigger writing profiles to disk when memory usage is
high.

This is controlled by two environment variables:

 - If $GOMEMLIMIT is unset, the profile dumping does not happen. This value is
   also used by the Go runtime to set a soft limit, and we intend to set it to
   something below where the OS will kill the process. https://pkg.go.dev/runtime#hdr-Environment_Variables
 - Files are written with os.CreateTemp(), so their location can be controlled
   with $TMPDIR.
@aarongable
Copy link
Copy Markdown
Contributor

Haven't read in detail yet, but for the question in the PR description: under the current logging regime, this could use blog.Get() to acquire a default logger for errors, instead of using fmt.Print directly. Under the upcoming logging regime, if this code were in cmd/ instead of cmd/boulder/, it could use the same backupLogger used by cmd.AuditPanic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants