This is an archive of the discontinued LLVM Phabricator instance.

[Support] Time profiler: support new PassManager
AbandonedPublic

Authored by anton-afanasyev on May 17 2019, 8:21 AM.

Details

Summary

Add time tracing of backend passes invoked by new PassManager.

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2019, 8:21 AM

I know this is in line with what is done in old-pm, but i find the middle-end names to be very useless.
In particular, why is the actual optimization pass name is always in the description, and the actual timeslice name is always the same generic "Opt???"?
IMHO the actual optimization pass name should be the Name, not Detail.

I know this is in line with what is done in old-pm, but i find the middle-end names to be very useless.
In particular, why is the actual optimization pass name is always in the description, and the actual timeslice name is always the same generic "Opt???"?
IMHO the actual optimization pass name should be the Name, not Detail.

We can change this in a separate commits in both new and old pm.
Same name "Opt???" makes the same color in a flamechart. Btw, have you tried Speedscope (https://www.speedscope.app) for visualization? It works better than chrome://tracing, trying to show details in chart boxes.

I know this is in line with what is done in old-pm, but i find the middle-end names to be very useless.
In particular, why is the actual optimization pass name is always in the description, and the actual timeslice name is always the same generic "Opt???"?
IMHO the actual optimization pass name should be the Name, not Detail.

We can change this in a separate commits in both new and old pm.

Same name "Opt???" makes the same color in a flamechart.

Yes, indeed.
I *believe* it also makes double-clicking on one select *all* the slices with that "Opt???" name.
In other words, how do i group by the pass name?
It can be argued either way which is more important, sure.

Btw, have you tried Speedscope (https://www.speedscope.app) for visualization? It works better than chrome://tracing, trying to show details in chart boxes.

No, i know it exists, but i didn't try it..

I'm not really familiar with new-PM.
Can this perhaps have a test?

philip.pfaffe requested changes to this revision.May 20 2019, 3:34 AM
philip.pfaffe added a subscriber: philip.pfaffe.

I might have fallen a bit out of the loop, but can you tell me a bit more details about the use case here? There is no in-tree support for new-PM backend passes currently, is this for an out-of-tree user?
What about all the other IRUnit nestings beyond function passes in module pipelines?

Those questions aside, I'm not happy with the implementation. It uses global state, which is bad on its own, but in a way that isn't remotely threadsafe. It also cannot be easily made threadsafe without bigger redesign. Therefore, this isn't going to work in the new PM.

In the new PassManager we have a quite nice instrumentation infrastructure, which is perfectly suited to hook tracers such as this one into the pipeline execution. I suggest implementing -ftime-trace on top of that infrastructure. That being said, it appears as if there's quite some overlap between this tracer and the pass timing things. Why is the existing mechanism insufficient? Is the difference really just the output format? In which case, why not make that customizable instead of rolling out a second timing instrumentation?

This revision now requires changes to proceed.May 20 2019, 3:34 AM

I might have fallen a bit out of the loop, but can you tell me a bit more details about the use case here? There is no in-tree support for new-PM backend passes currently, is this for an out-of-tree user?
What about all the other IRUnit nestings beyond function passes in module pipelines?

Those questions aside, I'm not happy with the implementation. It uses global state, which is bad on its own, but in a way that isn't remotely threadsafe. It also cannot be easily made threadsafe without bigger redesign. Therefore, this isn't going to work in the new PM.

In the new PassManager we have a quite nice instrumentation infrastructure, which is perfectly suited to hook tracers such as this one into the pipeline execution. I suggest implementing -ftime-trace on top of that infrastructure. That being said, it appears as if there's quite some overlap between this tracer and the pass timing things. Why is the existing mechanism insufficient? Is the difference really just the output format? In which case, why not make that customizable instead of rolling out a second timing instrumentation?

Hmm, thank you for noting this all, I'm not familiar with new PM. Could you please describe instrumentation infrastructure you are suggesting?

In essence, the infrastructure is a set of callbacks that you can register with PassBuilder. Your callbacks then get invoked at various points withing pipelines built by PB.

See StandardInstrumentations as well as its use in opt's NewPMDriver for an example.

anton-afanasyev abandoned this revision.Jun 3 2019, 8:14 AM

With new-pm soon being the default, i'm curious what's the plan with -ftime-trace?
Will it simply turn into a pumpkin? Is there an upcoming patch (along the lines of D62067#1511128)?

With new-pm soon being the default, i'm curious what's the plan with -ftime-trace?
Will it simply turn into a pumpkin? Is there an upcoming patch (along the lines of D62067#1511128)?

It still will be actual for FE part of profiler timers. What is the planned date of switching to new PM?

With new-pm soon being the default, i'm curious what's the plan with -ftime-trace?
Will it simply turn into a pumpkin? Is there an upcoming patch (along the lines of D62067#1511128)?

It still will be actual for FE part of profiler timers.

What is the planned date of switching to new PM?

"As soon as possible"?
I think it is all but guaranteed to finally happen this release cycle
https://lists.llvm.org/pipermail/llvm-dev/2019-August/134326.html
There's patch i think, but i can't find it.

Starting from D71059 time profiler supports multiple threads, this is a step to support new PassManager.
Regarding note about "why not to use new PM infrastructure for whole time profiler?" The current implementation of time profiler is independent and used by frontend (clang) and ThinLTO (lld). It is rather simple to use by adding just one line at the start of the profiled scope. I'm not sure new PM infrastructure is appropriate for it.

Here is the another patch for new pm support: D74516