question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve or New time profiling utility

See original GitHub issue

🚀 Feature

Currently, ignite provides only a basic time profiling tool : https://pytorch.org/ignite/master/contrib/handlers.html#ignite.contrib.handlers.time_profilers.BasicTimeProfiler

Which can print something like

----------------------------------------------------
| Time profiling stats (in seconds):                 |
 ----------------------------------------------------
total  |  min/index  |  max/index  |  mean  |  std

Processing function:
157.46292 | 0.01452/1501 | 0.26905/0 | 0.07730 | 0.01258

Dataflow:
6.11384 | 0.00008/1935 | 0.28461/1551 | 0.00300 | 0.02693

Event handlers:
2.82721

- Events.STARTED: []
0.00000

- Events.EPOCH_STARTED: []
0.00006 | 0.00000/0 | 0.00000/17 | 0.00000 | 0.00000

- Events.ITERATION_STARTED: ['PiecewiseLinear']
0.03482 | 0.00001/188 | 0.00018/679 | 0.00002 | 0.00001

- Events.ITERATION_COMPLETED: ['TerminateOnNan']
0.20037 | 0.00006/866 | 0.00089/1943 | 0.00010 | 0.00003

- Events.EPOCH_COMPLETED: ['empty_cuda_cache', 'training.<locals>.log_elapsed_time', ]
2.57860 | 0.11529/0 | 0.14977/13 | 0.12893 | 0.00790

- Events.COMPLETED: []
not yet triggered

What would be nice to have:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vfdev-5commented, Oct 21, 2020

@vfdev-5 Okay then for BC it seems the best option is to add a new class as HandlersTimeProfiler. I’ll do that.

@harsh8398 sounds good !

For handling custom events, its a bit tricky because like epoch and iteration event handlers we don’t know how many times they will get triggered. We can use something like this (https://discuss.pytorch.org/t/dynamically-extend-the-tensor/39553/2) for dynamically extending tensor whenever the handler is called. But I think it would get called so many times and it may consume time.

Let’s see this a bit later. I think handling custom events should not be too different from original events. Engine is aware of all events it could trigger and which handlers… If you could open a follow-up issue on that, it would be perfect 😃

1reaction
harsh8398commented, Oct 20, 2020

I’m done with profiler implementation. The output looks as follows: image

You can review the changes and suggest if any modifications required but there’s still some TODOs left before raising the PR. Which are as follows:

  • separate rows for Total, Dataflow and Processing stats
  • type hints
  • update write_results() as per new profiler stats format
  • update tests

I have one question, should we include handler times for GET_BATCH_STARTED and GET_BATCH_COMPLETED for calculating dataflow time? Previous implementation had this but I’m not sure if it was intentional.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Choose the Best Performance Profiling Tools - Stackify
Learn how to choose the best performance profiling tools to detect performance issues and improve your overall application performance.
Read more >
First look at profiling tools - Visual Studio (Windows)
To use the tool, choose Application Timeline in the Performance Profiler, and then choose Start. In your app, go through the scenario with...
Read more >
Fundamentals of Performance Profiling - SmartBear
Performance profilers are software development tools designed to help you analyze the performance of your applications and improve poorly performing ...
Read more >
Profile Your Code to Improve Performance - MATLAB & Simulink
Profiling is a way to measure the time it takes to run your code and identify where MATLAB ® spends the most time....
Read more >
All About Code Profiling | How to Choose the Right Tool
Customers love fast, clean, and efficient applications. Profiling code helps optimize applications, and consequently, the user experience.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found