Re: [PATCH 00/35] perf annotate: Use generic annotation line

From: Jiri Olsa
Date: Wed Oct 11 2017 - 15:11:05 EST


On Wed, Oct 11, 2017 at 12:27:09PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Oct 11, 2017 at 05:01:23PM +0200, Jiri Olsa escreveu:
> > hi,
> > I'm working on script profiling support and came up
>
> Can you describe what you mean by "script profiling" and "script
> annotation"?

I have some prototype code that allows to get the
internal script stack to the sample and display
it later on in report:

Samples: 20K of event 'cycles:ppp', Event count (approx.): 10598322780
Overhead Command Script File Symbol â
42.29% python3 /usr/lib64/python3.6/site-packages/hawkey/__init__.py [.] union+0xe â
17.17% python3 /usr/lib64/python3.6/site-packages/hawkey/__init__.py [.] run+0x0 â
16.80% python3 /usr/lib/python3.6/site-packages/dnf/cli/output.py [.] _skipped_packages+0x1e â
13.64% python3 N/A [.] 0x00007f9a96e655a2 â
1.48% python3 N/A [.] 0x00005584196c4844 â
0.71% python3 <frozen importlib._bootstrap> [.] _call_with_frames_removed+0x0 â
0.56% python3 <frozen importlib._bootstrap_external> [.] _compile_bytecode+0x0 â
0.55% python3 /usr/lib64/python3.6/site-packages/hawkey/__init__.py [.] run+0x0 â
0.23% python3 /usr/lib64/python3.6/sre_parse.py [.] _parse+0x288 â
0.20% python3 /usr/lib64/python3.6/collections/__init__.py [.] namedtuple+0x174 â
0.16% python3 N/A [.] 0x00007f9a89e9bc12 â
0.16% python3 <frozen importlib._bootstrap_external> [.] _path_stat+0x0 â


and annotate:

Percentâ # parse a simple pattern
â 471: subpattern = SubPattern(state) â
â
â # precompute constants into local variables
2.00 â 474: subpatternappend = subpattern.append â
â 475: sourceget = source.get â
2.00 â 476: sourcematch = source.match â
â 477: _len = len â
â 478: _ord = ord â
â
â 480: while True: â
â
6.00 â 482: this = source.next â
4.00 â 483: if this is None: â
â 484: break # end of pattern â
2.00 â 485: if this in "|)": â
â 486: break # end of subpattern â
10.00 â 487: sourceget() â
â
4.00 â 489: if verbose: â
â # skip whitespace and comments
4.00 â 491: if this in WHITESPACE: â
â 492: continue â
â 493: if this == "#": â
â 494: while True: â
2.00 â 495: this = sourceget() â
2.00 â 64: 496: if this is None or this == "\n": â
â 497: break â
â 498: continue â
â
6.00 â 500: if this[0] == "\\": â
2.00 â 501: code = _escape(source, this, state) â


it so far for python.. I plan to post it next week

jirka