using the qml profiler
play

Using The QML Profiler Ulf Hermann The Qt Company October 8, 2014 - PowerPoint PPT Presentation

Using The QML Profiler Ulf Hermann Why? What? How To Examples New Features Using The QML Profiler Ulf Hermann The Qt Company October 8, 2014 / Qt Developer Days 2014 1/28 Using The QML Outline Profiler Ulf Hermann Why? What? 1


  1. Using The QML Profiler Ulf Hermann Why? What? How To Examples New Features Using The QML Profiler Ulf Hermann The Qt Company October 8, 2014 / Qt Developer Days 2014 1/28

  2. Using The QML Outline Profiler Ulf Hermann Why? What? 1 Reasons for Using a Specialized Profiler for Qt Quick How To Examples New Features 2 The QML Profiler 3 Analysing Typical Problems 4 Live Examples of Profiling and Optimization 5 New Features for the QML Profiler 2/28

  3. Using The QML Outline Profiler Ulf Hermann Why? What? 1 Reasons for Using a Specialized Profiler for Qt Quick How To Examples New Features 2 The QML Profiler 3 Analysing Typical Problems 4 Live Examples of Profiling and Optimization 5 New Features for the QML Profiler 3/28

  4. Using The QML Classical optmization workflow Profiler Ulf Hermann Why? Minimize total time a program will take to run: What? How To • Instrument binary to count and time function calls Examples • Or use an emulator that keeps track of function calls New Features Create call statistics to see: • which functions took most time • which functions are called most often Go back and optimize those. Problematic with Qt Quick applications ... 4/28

  5. Using The QML Profiling JIT-compiled code Profiler Ulf Hermann Why? • What functions does it What? call there? How To Examples • No useful results on QV4::SimpleScriptFunction::call(QV4::Managed*,QV4::CallData*) New Features JIT-compiled or 0x0000000012c149f0 0x00000000127a0000 interpreted code from general purpose 0x000000001279a000 0x00000000127a3840 profilers QV4::Runtime::callProperty(...) QV4::Runtime::setProperty(...) • No symbolic information Profiling QML code with Valgrind available • No stack unwinding with non-emulating profilers 5/28

  6. Using The QML “Long” run time Profiler Ulf Hermann Single Signal Handler that Why? runs for 40ms What? How To • doesn’t make big dent Examples in statistics New Features • leads to 2 dropped frames in a row • might be harmless • when does it run? Relate single events on a timescale to pin down problems. 6/28

  7. Using The QML “Many” calls Profiler Ulf Hermann Why? What? How To Examples New Features Badly timed object creation • Time for each object creation isn’t significant here. • Number of calls may be more interesting, but ... • their distribution over the frames is most important! 7/28

  8. Using The QML Outline Profiler Ulf Hermann Why? What? 1 Reasons for Using a Specialized Profiler for Qt Quick How To Examples New Features 2 The QML Profiler 3 Analysing Typical Problems 4 Live Examples of Profiling and Optimization 5 New Features for the QML Profiler 8/28

  9. Using The QML The QML Profiler Profiler Ulf Hermann Why? In Analyze mode of Qt Creator What? How To Examples New Features 1 start/stop profiling 2 control execution directly or profile external process 3 switch recording on and off while application is running to receive traces for specific time ranges. 4 select event types to be recorded (Qt Creator 3.3+) 5 clear current trace Save and load trace files from context menu. 9/28

  10. Using The QML Timeline View Profiler Ulf Hermann Why? What? • Pixmap Cache: slow loading How To Examples or large pictures New Features • Animations, Scene Graph: composition of scene graph • Memory Usage: JavaScript heap and garbage collector • Binding, Signal Handling, JavaScript: QML/JavaScript execution times 10/28

  11. Using The QML Events View Profiler Ulf Hermann Why? What? How To Examples New Features • Statistical profile of QML/JavaScript • For problems that lend themselves to the classical workflow • Optimize the overall most expensive bits to get a general speedup 11/28

  12. Using The QML Outline Profiler Ulf Hermann Why? What? 1 Reasons for Using a Specialized Profiler for Qt Quick How To Examples New Features 2 The QML Profiler 3 Analysing Typical Problems 4 Live Examples of Profiling and Optimization 5 New Features for the QML Profiler 12/28

  13. Using The QML It’s slow. What is wrong? Profiler Ulf Hermann Why? • Too much JavaScript executed in few frames? What? How To • All JavaScript must return before GUI thread advances Examples • Frames delayed/dropped if GUI thread not ready New Features • Result: Unresponsive, stuttering UI • Creating/Painting/Updating invisible items? • Takes time in GUI thread • Same effect as “Too much JavaScript” • Triggering long running C++ functions? • Paint methods, signal handlers, etc. triggered from QML • Also takes time in GUI thread • Harder to see in the QML profiler as C++ isn’t profiled 13/28

  14. Using The QML Too much Javascript Profiler Ulf Hermann Why? What? How To Examples New Features • Watch frame rate in Animations and Scene Graph • Gaps and orange animation events are bad • JavaScript category shows functions and run time • Stay under 1000 / 60 ≈ 16ms per frame 14/28

  15. Using The QML Invisible Items Profiler Ulf Hermann Why? What? How To Examples New Features • Check again for dropped frames • Check for many short bindings or signal handlers => Too many items updated per frame • QSG_VISUALIZE=overdraw shows scene layout • Watch for items outside the screen or underneath visible elements 15/28

  16. Using The QML Long running C++ functions Profiler Ulf Hermann Why? What? How To Examples New Features • Dropped frames, but no JavaScript running? • Large unexplained gaps in the timeline? • Check your custom QQuickItem implementations • Use general purpose profiler to explore the details 16/28

  17. Using The QML Outline Profiler Ulf Hermann Why? What? 1 Reasons for Using a Specialized Profiler for Qt Quick How To Examples New Features 2 The QML Profiler 3 Analysing Typical Problems 4 Live Examples of Profiling and Optimization 5 New Features for the QML Profiler 17/28

  18. Using The QML Example 1: Too much JavaScript Profiler Ulf Hermann Glitch in SameGame example when starting new game Why? What? How To Examples New Features 18/28

  19. Using The QML Example 1: Too much JavaScript Profiler Ulf Hermann Glitch in SameGame example when starting new game Why? What? • All items created from one JavaScript function call How To Examples • Takes about 100ms New Features • About 7 dropped frames in a row • Enough unused CPU time during menu removal animation 18/28

  20. Using The QML Example 1: Too much JavaScript Profiler Ulf Hermann Glitch in SameGame example when starting new game Why? What? • All items created from one JavaScript function call How To Examples • Takes about 100ms New Features • About 7 dropped frames in a row • Enough unused CPU time during menu removal animation Solution: • Create invisible items during menu animation • Later only set them visible • Setting visibility is cheaper than creating items 18/28

  21. Using The QML Conventions for profiling Qt Creator Profiler Ulf Hermann Why? • gray color scheme: profiling one of the others What? How To Examples • red color scheme: buggy pre-3.0 as “bad” example New Features • green color scheme: v3.3 preview • blue color scheme: patched v3.3 preview • Trace files are just loaded into “colored” Qt Creators to trigger activity. Don’t interpret the data. 19/28

  22. Using The QML Example 2: Even more JavaScript Profiler Ulf Hermann QML Profiler stutters on horizontal resizing. Why? What? How To Examples New Features 20/28

  23. Using The QML Example 2: Even more JavaScript Profiler Ulf Hermann QML Profiler stutters on horizontal resizing. Why? What? • Overview always iterates all events to paint itself How To • is implemented in JavaScript Examples New Features • but: only updated on loading and resizing 20/28

  24. Using The QML Example 2: Even more JavaScript Profiler Ulf Hermann QML Profiler stutters on horizontal resizing. Why? What? • Overview always iterates all events to paint itself How To • is implemented in JavaScript Examples New Features • but: only updated on loading and resizing Solution 1 : • Stretch the code over multiple frames • Use Timer to trigger deferred JavaScript execution • onTriggered should not take longer than a frame (around 16ms) • Downside: Overview painting is “animated” now 1 with potential for further optimization ... 20/28

  25. Using The QML Example 3: Painting outside viewport Profiler Ulf Hermann Slow scrolling if timeline categories expanded Why? What? How To Examples New Features 21/28

  26. Using The QML Example 3: Painting outside viewport Profiler Ulf Hermann Slow scrolling if timeline categories expanded Why? What? • Coordinate system marks cover a large space in How To vertical direction Examples New Features • can take a long time to paint (up to 10ms) • are mostly invisible most of the time. 21/28

  27. Using The QML Example 3: Painting outside viewport Profiler Ulf Hermann Slow scrolling if timeline categories expanded Why? What? • Coordinate system marks cover a large space in How To vertical direction Examples New Features • can take a long time to paint (up to 10ms) • are mostly invisible most of the time. Solution 2 : • Only paint visible part of coordinate system • Directly set virtual contentHeight on Flickable • Painted area “sliding” in virtual contentHeight • Reduces painting time to about 1 - 2ms 2 with potential for further optimization ... 21/28

Recommend


More recommend