Skip to content
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

-ftime-trace Frontend timer misses Codegen Function for template functions #41314

Closed
rgal opened this issue May 21, 2019 · 3 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category

Comments

@rgal
Copy link
Collaborator

rgal commented May 21, 2019

Bugzilla Link 41969
Resolution FIXED
Resolved on Sep 05, 2019 02:17
Version trunk
OS All
Attachments [Screenshot of chrome:https://user-images.githubusercontent.com/8567076/143759236-feded57b-025c-4a2c-98c7-dc3111f88eb4.gz)
CC @anton-afanasyev,@zygoloid

Extended Description

Clang "CodeGen Function" timers from -ftime-trace for some functions falls outside of the "Frontend" timer and thus between Frontend and Backend (see attached screenshot). I think this should be counted under Frontend. In the original motivating example the time between "Frontend" and "Backend" was 11% of the overall execution time so fairly significant.

e.g. at r361164

Apply patch to trace ALL durations however small (to allow small reproducible)

diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index bc234081564..f63847a8a28 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -65,8 +65,8 @@ struct TimeTraceProfiler {
E.Duration = steady_clock::now() - E.Start;

 // Only include sections longer than TimeTraceGranularity msec.
  • if (duration_cast(E.Duration).count() > TimeTraceGranularity)
  •  Entries.emplace_back(E);
    
  • //if (duration_cast(E.Duration).count() > TimeTraceGranularity)

  • Entries.emplace_back(E);

    // Track total time taken by each "name", but only the topmost levels of
    // them; e.g. if there's a template instantiation that instantiates other

$ cat test.cpp
template void foo(T) {}
void bar() { foo(0); }
$ clang -c -ftime-trace test.cpp

test.json now has CodeGen Function for foo between "Frontend" and "Backend"

{
"traceEvents": [
...
{
"args": {
"detail": ""
},
"dur": 1451,
"name": "Frontend",
"ph": "X",
"pid": 1,
"tid": 0,
"ts": 3722
},
{
"args": {
"detail": "foo"
},
"dur": 66,
"name": "CodeGen Function",
"ph": "X",
"pid": 1,
"tid": 0,
"ts": 5177
},
...
{
"args": {
"detail": ""
},
"dur": 2866,
"name": "Backend",
"ph": "X",
"pid": 1,
"tid": 0,
"ts": 5287
},
...
}

@rgal
Copy link
Collaborator Author

rgal commented May 21, 2019

assigned to @anton-afanasyev

@anton-afanasyev
Copy link
Contributor

Here is a review for fix: https://reviews.llvm.org/D63325
I've added second Frontend time trace entry for HandleTranslateUnit() codegen function.

@rgal
Copy link
Collaborator Author

rgal commented Sep 5, 2019

Fixed in r369308.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

2 participants