From d5a760b4b9d70211a2e2b9082ae8b6b3ab77dbe3 Mon Sep 17 00:00:00 2001 From: Mason Chang Date: Thu, 31 Oct 2024 16:23:27 -0700 Subject: [PATCH] Limit TSL stack size to 10 PiperOrigin-RevId: 691971293 --- xla/service/gpu/metrics.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xla/service/gpu/metrics.cc b/xla/service/gpu/metrics.cc index b3bd486191285..7ceb67443b921 100644 --- a/xla/service/gpu/metrics.cc +++ b/xla/service/gpu/metrics.cc @@ -112,6 +112,11 @@ void RecordGpuCompilerStacktrace() { stack.pop_front(); stack.pop_back(); + const int kMaxStackDepth = 10; + while (stack.size() > kMaxStackDepth) { + stack.pop_back(); + } + // Stack traces with addresses would make too many unique streamz cells. // We only care about the actual call stack. // Format chars added by tsl::CurrentStackTrace().