Skip to content

Conversation

@rnk
Copy link
Collaborator

@rnk rnk commented May 5, 2025

These tests have been flaky since they were merged into the AllClangUnitTests binary, but the flakiness is inherent to the nature of timer-based tests.

These tests have been flaky since they were merged into the
AllClangUnitTests binary, but the flakiness is inherent to the nature of
timer-based tests.
@rnk rnk requested review from AaronBallman, aeubanks, dyung and usx95 May 5, 2025 23:26
@llvmbot llvmbot added the clang Clang issues not falling into any other category label May 5, 2025
@llvmbot
Copy link
Member

llvmbot commented May 5, 2025

@llvm/pr-subscribers-clang

Author: Reid Kleckner (rnk)

Changes

These tests have been flaky since they were merged into the AllClangUnitTests binary, but the flakiness is inherent to the nature of timer-based tests.


Full diff: https://github.com/llvm/llvm-project/pull/138613.diff

1 Files Affected:

  • (modified) clang/unittests/Support/TimeProfilerTest.cpp (+10)
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp b/clang/unittests/Support/TimeProfilerTest.cpp
index f8053f2dfce48..7698742426dfc 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -155,6 +155,16 @@ std::string buildTraceGraph(StringRef Json) {
       bool InsideCurrentEvent =
           Event.TimestampBegin >= EventStack.top()->TimestampBegin &&
           Event.TimestampEnd <= EventStack.top()->TimestampEnd;
+
+      // Presumably due to timer rounding, PerformPendingInstantiations often
+      // appear to be within the timer interval of the immediately previous
+      // event group. We always know these events occur at level 1, not level 2,
+      // in our tests, so pop an event in that case.
+      if (InsideCurrentEvent && Event.Name == "PerformPendingInstantiations" &&
+          EventStack.size() == 2) {
+        InsideCurrentEvent = false;
+      }
+
       if (!InsideCurrentEvent)
         EventStack.pop();
       else

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rnk rnk merged commit 47fb5bd into llvm:main May 8, 2025
13 checks passed
zmodem added a commit that referenced this pull request Nov 6, 2025
@zmodem
Copy link
Collaborator

zmodem commented Nov 6, 2025

Was there a bug filed for this somewhere?

We're still seeing the flakiness on Mac, see https://crbug.com/394500612

I've disabled the test in http://github.com/llvm/llvm-project/commit/bf2653ed770f737a7950047f81724a104a7d0c79

@Izaron in case you want to look into it.

llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants