From eb08ed451813e50384f4b30864216c732add40d9 Mon Sep 17 00:00:00 2001 From: milen <94537774+taratorio@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:07:37 +0100 Subject: [PATCH] dbg: env var for heap profile output file path (#12398) relates to https://github.com/erigontech/erigon/issues/11387#issuecomment-2382684325 port of https://github.com/erigontech/erigon/pull/12400 to E2 --- erigon-lib/common/dbg/experiments.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erigon-lib/common/dbg/experiments.go b/erigon-lib/common/dbg/experiments.go index 7dfe8008cbf..d54b79ab670 100644 --- a/erigon-lib/common/dbg/experiments.go +++ b/erigon-lib/common/dbg/experiments.go @@ -35,6 +35,7 @@ var ( // force skipping of any non-Erigon2 .torrent files DownloaderOnlyBlocks = EnvBool("DOWNLOADER_ONLY_BLOCKS", false) saveHeapProfile = EnvBool("SAVE_HEAP_PROFILE", false) + heapProfileFilePath = EnvString("HEAP_PROFILE_FILE_PATH", "") ) var StagesOnlyBlocks = EnvBool("STAGES_ONLY_BLOCKS", false) @@ -381,7 +382,12 @@ func SaveHeapProfileNearOOM(opts ...SaveHeapOption) { } // above 45% - filePath := filepath.Join(os.TempDir(), "erigon-mem.prof") + var filePath string + if heapProfileFilePath == "" { + filePath = filepath.Join(os.TempDir(), "erigon-mem.prof") + } else { + filePath = heapProfileFilePath + } if logger != nil { logger.Info("[Experiment] saving heap profile as near OOM", "filePath", filePath) }