GNOME Bugzilla – Bug 612186
callgraph profiling support
Last modified: 2015-06-26 12:49:27 UTC
xsltproc --profile is quite helpful to find out in which parts of xsl style sheets most time ist spend. Now if one want to optimize that there are always two ways: 1.) make the hostspots use less cpu 2.) avoid calling expensive functions For that a callgraph is useful. When using oprofile to profile code I use this script [1] to render the call graph. [1] http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
Created attachment 155552 [details] [review] add callgraph output This patch also tracks who called a template and how often. Based on that the output of xsltproc --profile now also contains a gprof alike callgraph. xsltproc --profile data.xsl data.xml 2>report.txt cat report.txt | gprof2dot.py -e 0.01 -n 0.01 | dot -Tpng -o report.pn
Created attachment 155553 [details] example report when using the docbook stylesheets
This needs a small workaround in gprof2dot still: --- /home/ensonic/bin/gprof2dot.orig.py 2010-03-08 15:02:18.000000000 +0200 +++ /home/ensonic/bin/gprof2dot.py 2010-03-08 14:09:13.437841498 +0200 @@ -367,6 +367,8 @@ return function[outevent] def _integrate_call(self, call, outevent, inevent): + if outevent not in call: + return 0 assert outevent not in call assert call.ratio is not None callee = self.functions[call.callee_id] see http://code.google.com/p/jrfonseca/issues/detail?id=32
Created attachment 155561 [details] [review] add callgraph output - improved match-template naming (strip spaces and add mode) - added function list
Created attachment 157669 [details] [review] add callgraph output This now addresses a remaining FIXME: and frees the profile data in xmlFreetemplate(). No idea why I did not found this so far. Minor issue. The file libxslt/xslt.c seem to had some encoding issue and thus my patch as one unrelated hunk - what is this supposed to read? I could correct that as a separate patch and commit right away. @@ -5167,7 +5172,7 @@ xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) { /* * TODO: We need a standardized function for extraction * of namespace names and local names from QNames. - * Don't use xsltGetQNameURI() as it cannot channeö + * Don't use xsltGetQNameURI() as it cannot channe� * reports through the context. */ modeURI = xsltGetQNameURI(templNode, &prop);
This looks really nice. Whenever I profile the Yelp stylesheets, I spend a lot of time sifting through mostly irrelevant information to find the gems. That callgraph makes it a lot easier.
As per HACKING file I committed the feature. commit 193322ac0519651d846eed2377f13d5b214fb108 Author: Stefan Kost <ensonic@users.sf.net> Date: Mon Mar 8 14:58:00 2010 +0200 profiling: add callgraph report This patch also tracks who called a template and how often. Based on that the output of xsltproc --profile now also contains a gprof alike callgraph. If available posix monotonic clocks are the preferred way to get timestamps.
Lets see if the gprof2dot hack can be eliminated https://github.com/jrfonseca/gprof2dot/issues/4