Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[clang] Deflake the TimeProfile support tests #138613

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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, usx95, dyung and aeubanks 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!

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.

4 participants