After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 612186 - callgraph profiling support
callgraph profiling support
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-08 12:49 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2015-06-26 12:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add callgraph output (11.85 KB, patch)
2010-03-08 12:59 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
none Details | Review
example report when using the docbook stylesheets (416.55 KB, image/png)
2010-03-08 13:00 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
  Details
add callgraph output (12.35 KB, patch)
2010-03-08 14:31 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
none Details | Review
add callgraph output (15.35 KB, patch)
2010-04-01 08:31 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
none Details | Review

Description Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 12:49:29 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
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 12:59:45 UTC
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
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 13:00:35 UTC
Created attachment 155553 [details]
example report when using the docbook stylesheets
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 13:07:47 UTC
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
Comment 4 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 14:31:00 UTC
Created attachment 155561 [details] [review]
add callgraph output

- improved match-template naming (strip spaces and add mode)
- added function list
Comment 5 Stefan Sauer (gstreamer, gtkdoc dev) 2010-04-01 08:31:49 UTC
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);
Comment 6 Shaun McCance 2010-04-09 14:44:29 UTC
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.
Comment 7 Stefan Sauer (gstreamer, gtkdoc dev) 2010-06-21 18:34:03 UTC
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.
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2015-06-26 12:49:27 UTC
Lets see if the gprof2dot hack can be eliminated
https://github.com/jrfonseca/gprof2dot/issues/4