launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #07793
New profiling/analysis features
++profile++ has a few new features, and "make run LP_DEBUG_SQL_EXTRA=1" has a new trick too.
Get a current launchpad.dev and go to https://launchpad.dev/++profile++ to read more details and usage instructions. https://qastaging.launchpad.net/++profile++ has #2 now for the Launchpad team, and should have #4 within 24 hours.
(1) You can add "from lib.services.profile import profiling" and then "with profiling(): ..." in your code to get inline profiling of certain parts of your code. It aggregates multiple calls into a single stats result at the end of the request, available in a in-browser summary and a pstats log file.
(2) ++profile++ lets you use pstats output now (++profile++pstats). This Python standard library approach lets you dig into stats a bit deeper than KCacheGrind does, albeit with less graphical goodness. KCacheGrind-friendly output is still available as well (++profile++callgrind, as well as legacy ++profile++log).
(3) "make run LP_DEBUG_SQL_EXTRA=1" now includes page template and traversal hints in the stack traces so you can see what page templates and traversals were in play for the SQL calls. I've found this to be very nice.
You can also include your own information for the traceback. The easiest way is to define a variable named "__traceback_info__". This variable will be stringified and rendered in the traceback. There's also a more involved and somewhat lazier variant, used by the pagetemplate code, that people can ask about if they want details.
(4) ++profile++ lets you see the a sql trace similar to "make run LP_DEBUG_SQL_EXTRA=1" (++profile++sqltrace). This lets you get the analysis on the fly, without restarting, which will be particularly nice for qastaging and staging once the code lands. This includes a bit of simple OOPS-tool like analysis on the page. It also includes the traceback template information described in (3) above, rendered in a more eye-catching way.
Gary
Follow ups