My favorites | Sign in
Project Home
Checkout   Browse   Changes  
Changes to /trunk/HACKING
r1384 vs. r1396 Compare: vs.  Format:
Revision r1396
Go to: 
Project members, sign in to write a code review
/trunk/HACKING   r1384 /trunk/HACKING   r1396
1 # vim: ts=8 sw=2 sts=0 noexpandtab: 1 # vim: ts=8 sw=2 sts=0 noexpandtab:
2 # $Id$ 2 # $Id$
3 3
4 HACKING Devel::NYTProf 4 HACKING Devel::NYTProf
5 ====================== 5 ======================
6 6
7 We encourage hacking Devel::NYTProf! 7 We encourage hacking Devel::NYTProf!
8 8
9 OBTAINING THE CURRENT RELEASE 9 OBTAINING THE CURRENT RELEASE
10 ----------------------------- 10 -----------------------------
11 The current official release can be obtained from CPAN 11 The current official release can be obtained from CPAN
12 http://search.cpan.org/dist/Devel-NYTProf/ 12 http://search.cpan.org/dist/Devel-NYTProf/
13 13
14 OBTAINING THE LATEST DEVELOPMENT CODE 14 OBTAINING THE LATEST DEVELOPMENT CODE
15 ------------------------------------- 15 -------------------------------------
16 You can grab the head of the latest trunk code from the Google Code repository, see 16 You can grab the head of the latest trunk code from the Google Code repository, see
17 http://code.google.com/p/perl-devel-nytprof/source/checkout 17 http://code.google.com/p/perl-devel-nytprof/source/checkout
18 18
19 CONTRIBUTING 19 CONTRIBUTING
20 ------------ 20 ------------
21 Please work with the latest code from the repository - see above. 21 Please work with the latest code from the repository - see above.
22 22
23 Small patches can be uploaded via the issue tracker at 23 Small patches can be uploaded via the issue tracker at
24 http://code.google.com/p/perl-devel-nytprof/issues/list 24 http://code.google.com/p/perl-devel-nytprof/issues/list
25 25
26 For larger changes please talk to us first via the mailing list at 26 For larger changes please talk to us first via the mailing list at
27 http://code.google.com/p/perl-devel-nytprof/source/checkout 27 http://code.google.com/p/perl-devel-nytprof/source/checkout
28 28
29 When developing, please ensure that no new compiler warnings are output. 29 When developing, please ensure that no new compiler warnings are output.
30 30
31 TESTING 31 TESTING
32 ------- 32 -------
33 Please try to add tests covering any changes you make. 33 Please try to add tests covering any changes you make.
34 34
35 You can run individual tests like this: 35 You can run individual tests like this:
36 36
37 perl -Mblib t/30-util.t 37 perl -Mblib t/30-util.t
38 38
39 Most tests include some underlying perl code that's being profiled. 39 Most tests include some underlying perl code that's being profiled.
40 Either as a .p file, which can be profiled like this: 40 Either as a .p file, which can be profiled like this:
41 41
42 perl -Mblib -MDevel::NYTProf t/test01.p 42 perl -Mblib -MDevel::NYTProf t/test01.p
43 43
44 or embedded at the end of a t/*.t file, which can be profiled like this: 44 or embedded at the end of a t/*.t file, which can be profiled like this:
45 45
46 perl -Mblib -MDevel::NYTProf -x t/70-subname 46 perl -Mblib -MDevel::NYTProf -x t/70-subname
47 47
48 The output will be in the ./nytprof.out file. 48 The output will be in the ./nytprof.out file.
49 49
50 RESOURCES 50 RESOURCES
51 --------- 51 ---------
52 Google Code: 52 Google Code:
53 http://code.google.com/p/perl-devel-nytprof/ 53 http://code.google.com/p/perl-devel-nytprof/
54 54
55 Google Devel Group (must subscribe here): 55 Google Devel Group (must subscribe here):
56 http://groups.google.com/group/develnytprof-dev 56 http://groups.google.com/group/develnytprof-dev
57 57
58 NYTimes Open Code Blog: 58 NYTimes Open Code Blog:
59 http://open.nytimes.com/ 59 http://open.nytimes.com/
60 60
61 TODO (unsorted, unprioritized, unconsidered, even unreasonable and daft :) 61 TODO (unsorted, unprioritized, unconsidered, even unreasonable and daft :)
62 ---- 62 ----
63 63
64 *** For build/test 64 *** For build/test
65 65
66 Add (very) basic nytprofhtml test (ie it runs and produces output) 66 Add (very) basic nytprofhtml test (ie it runs and produces output)
67 67
68 Add tests for evals in regex: s/.../ ...perl code... /e 68 Add tests for evals in regex: s/.../ ...perl code... /e
69 69
70 Add tests for -block and -sub csv reports. 70 Add tests for -block and -sub csv reports.
71 71
72 Add tests with various kinds of blocks and loops (if, do, while, until, etc). 72 Add tests with various kinds of blocks and loops (if, do, while, until, etc).
73 73
74 Add mechanism to specify inside the .p file that NYTProf 74 Add mechanism to specify inside the .p file that NYTProf
75 should not be loaded via the command line. That's needed to test 75 should not be loaded via the command line. That's needed to test
76 behaviors in environments where perl is init'd first. Such as mod_perl. 76 behaviors in environments where perl is init'd first. Such as mod_perl.
77 Then we can test things like not having the sub line range for some subs. 77 Then we can test things like not having the sub line range for some subs.
78 78
79 *** For core only 79 *** For core only
80 80
81 See MemoryProfiling.pod file 81 See MemoryProfiling.pod file
82 82
83 Store raw NYTPROF option string in the data file. 83 Store raw NYTPROF option string in the data file.
84 Include parsed version in report index page. 84 Include parsed version in report index page.
85 85
86 Add actual size and mtime of fid to data file. (Already in data file as zero, 86 Add actual size and mtime of fid to data file. (Already in data file as zero,
87 just needs the stat() call.) Don't alter errno. 87 just needs the stat() call.) Don't alter errno.
88 88
89 Add help option which would print a summary of the options and exit. 89 Add help option which would print a summary of the options and exit.
90 Could also print list of available clocks for the clock=N option 90 Could also print list of available clocks for the clock=N option
91 (using a set of #ifdef's) 91 (using a set of #ifdef's)
92 92
93 The subroutine profiler could calculate the running variance of the samples 93 The subroutine profiler could calculate the running variance of the samples
94 using this logic http://www.johndcook.com/standard_deviation.html 94 using this logic http://www.johndcook.com/standard_deviation.html
95 so the reports can display the standard deviation. 95 so the reports can display the standard deviation.
96 96
97 Replace DB::enable_profiling() and DB::disable_profiling() with $DB::profile = 1|0; 97 Replace DB::enable_profiling() and DB::disable_profiling() with $DB::profile = 1|0;
98 That a more consistent API with $DB::single etc., but more importantly it lets 98 That a more consistent API with $DB::single etc., but more importantly it lets
99 users leave the code in place when NYTProf is not loaded. It'll just do nothing, 99 users leave the code in place when NYTProf is not loaded. It'll just do nothing,
100 whereas currently the user will get a fatal error if NYTProf isn't loaded. 100 whereas currently the user will get a fatal error if NYTProf isn't loaded.
101 It also allows smart things like use of local() for temporary overrides. 101 It also allows smart things like use of local() for temporary overrides.
102 102
103 Combine current profile_* globals into a single global int using bit fields. 103 Combine current profile_* globals into a single global int using bit fields.
104 That way assigning to $DB::profile can offer a finer degree of control. 104 That way assigning to $DB::profile can offer a finer degree of control.
105 Specifically to enable/disable the sub or statement profiler separately. 105 Specifically to enable/disable the sub or statement profiler separately.
106 106
107 Add mechanism to enable control of profiling on a per-sub-name and/or 107 Add mechanism to enable control of profiling on a per-sub-name and/or
108 per-package-name basis. For example, specify a regex and whenever a sub is 108 per-package-name basis. For example, specify a regex and whenever a sub is
109 entered (for the first time, to make it cheap) check if the sub name matches 109 entered (for the first time, to make it cheap) check if the sub name matches
110 the regex. If it does then save the current $DB::profile value and set a new one. 110 the regex. If it does then save the current $DB::profile value and set a new one.
111 When the sub exits restore the previous $DB::profile value. 111 When the sub exits restore the previous $DB::profile value.
112 112
113 Work around OP_UNSTACK bug (http://rt.perl.org/rt3/Ticket/Display.html?id=60954) 113 Work around OP_UNSTACK bug (http://rt.perl.org/rt3/Ticket/Display.html?id=60954)
114 while ( foo() ) { # all calls to foo should be from here 114 while ( foo() ) { # all calls to foo should be from here
115 ... 115 ...
116 ... # no calls to foo() should appear here 116 ... # no calls to foo() should appear here
117 } 117 }
118 118
119 *** For core and reports 119 *** For core and reports
120 120
121 Add @INC to data file so reports can be made more readable by removing 121 Add @INC to data file so reports can be made more readable by removing
122 (possibly very long) library paths where appropriate. 122 (possibly very long) library paths where appropriate.
123 Tricky thing is that @INC can change during the life of the program. 123 Tricky thing is that @INC can change during the life of the program.
124 One approach might be to output it whenever we assign a new fid 124 One approach might be to output it whenever we assign a new fid
125 but only if different to the last @INC that was ouput. 125 but only if different to the last @INC that was ouput.
126 126
127 Add marker with timestamp for phases BEGIN, CHECK, INIT, END 127 Add marker with timestamp for phases BEGIN, CHECK, INIT, END
128 (could combine with pid marker) 128 (could combine with pid marker)
129 Add marker with timestamp for enable_profile and disable_profile. 129 Add marker with timestamp for enable_profile and disable_profile.
130 Could also dump-and-zero the sub profiler data so we could report per-phase timing. 130 Could also dump-and-zero the sub profiler data so we could report per-phase timing.
131 The goals here are to 131 The goals here are to
132 a) know how long the different phases of execution took mostly for general interest, and 132 a) know how long the different phases of execution took mostly for general interest, and
133 b) know how much time was spent with the profiler enabled to calculate accurate 133 b) know how much time was spent with the profiler enabled to calculate accurate
134 percentages and also be able to spot 'leaks' in the data processing (e.g. if 134 percentages and also be able to spot 'leaks' in the data processing (e.g. if
135 the sum of the statement times don't match the time spent with the profiler 135 the sum of the statement times don't match the time spent with the profiler
136 enabled, due to nested string evals for example). 136 enabled, due to nested string evals for example).
137 137
138 Add flags to sub call info to indicate what phase (BEGIN, etc) the call 138 Add flags to sub call info to indicate what phase (BEGIN, etc) the call
139 happened in. That'll allow call graphs to ignore BEGIN-time calls 139 happened in. That'll allow call graphs to ignore BEGIN-time calls
140 (which tend to make graphviz output too noisy to be useful). 140 (which tend to make graphviz output too noisy to be useful).
141 141
142 *** For reports only 142 *** For reports only
143 143
144 ::Reader and its data structures need to be refactored to death. 144 ::Reader and its data structures need to be refactored to death.
145 The whole reporting framework needs a rewrite to use a single 'thin' command 145 The whole reporting framework needs a rewrite to use a single 'thin' command
146 line and classes for the Model (lines, files, subs), View (html, csv etc), 146 line and classes for the Model (lines, files, subs), View (html, csv etc),
147 and Controller (composing views to form reports). 147 and Controller (composing views to form reports).
148 Dependent on a richer data model. 148 Dependent on a richer data model.
149 149
150 Then rework bin/ntyprof* to use the new subclasses 150 Then rework bin/ntyprof* to use the new subclasses
151 Ideally end up with a single nytprof command that just sets up the appropriate 151 Ideally end up with a single nytprof command that just sets up the appropriate
152 classes to do the work. 152 classes to do the work.
153 153
154 Trim leading @INC portion from filename in __ANON__[/very/long/path/...] 154 Trim leading @INC portion from filename in __ANON__[/very/long/path/...]
155 in report output. (Keep full path in link/tooltip/title as it may be ambiguous when shortened). 155 in report output. (Keep full path in link/tooltip/title as it may be ambiguous when shortened).
156 156
157 Add help link in reports. Could go to docs page on search.cpan.org. 157 Add help link in reports. Could go to docs page on search.cpan.org.
158 158
159 Add a 'permalink' icon (eg infinity symbol) to the right of lines that define 159 Add a 'permalink' icon (eg infinity symbol) to the right of lines that define
160 subs to make it easer to email/IM links to particular places in the code. 160 subs to make it easer to email/IM links to particular places in the code.
161 161
162 Report could track which subs it has reported caller info for 162 Report could track which subs it has reported caller info for
163 and so be able to identify subs that were called but haven't been included 163 and so be able to identify subs that were called but haven't been included
164 in the report because we didn't know where the sub was. 164 in the report because we didn't know where the sub was.
165 They could them be included in a separate 'miscellaneous' page. 165 They could them be included in a separate 'miscellaneous' page.
166 This is a more general way to view the problem of xsubs in packages 166 This is a more general way to view the problem of xsubs in packages
167 for which we don't have any perl source code. 167 for which we don't have any perl source code.
168 168
169 Consider restoring inclusive-time treemap with an appropriate description 169 Consider restoring inclusive-time treemap with an appropriate description
170 to explain how to interpret it. 170 to explain how to interpret it.
171 171
172 *** Other - mostly unsorted - stuff *** 172 *** Other - mostly unsorted - stuff ***
173 173
174 Intercept all opcodes that may fork and run perl code in the child 174 Intercept all opcodes that may fork and run perl code in the child
175 ie fork, open, entersub (ie xs), others? 175 ie fork, open, entersub (ie xs), others?
176 and fflush before executing the op (so fpurge isn't strictly required) 176 and fflush before executing the op (so fpurge isn't strictly required)
177 and reinit_if_forked() afterwards 177 and reinit_if_forked() afterwards
178 add option to force reinit_if_forked check per stmt just-in-case 178 add option to force reinit_if_forked check per stmt just-in-case
179 Alternatively it might be better to use pthread_atfork() [if available] with a 179 Alternatively it might be better to use pthread_atfork() [if available] with a
180 child handler. The man page says "Remember: only async-cancel-safe functions 180 child handler. The man page says "Remember: only async-cancel-safe functions
181 are allowed on the child side of fork()" so it seems that the safe thing to do 181 are allowed on the child side of fork()" so it seems that the safe thing to do
182 is to use a volatile flag variable, and change its value in the handler to 182 is to use a volatile flag variable, and change its value in the handler to
183 signal to the main code. 183 signal to the main code.
184 184
185 Support profiling programs which use threads: 185 Support profiling programs which use threads:
186 - move all relevant globals into a structure 186 - move all relevant globals into a structure
187 - add lock around output to file 187 - add lock around output to file
188 188
189 Set options via import so perl -d:NYTProf=... works. Very handy. May need 189 Set options via import so perl -d:NYTProf=... works. Very handy. May need
190 alternative option syntax. Also perl gives special meaning to 't' option 190 alternative option syntax. Also perl gives special meaning to 't' option
191 (threads) so we should reserve the same for eventual thread support. 191 (threads) so we should reserve the same for eventual thread support.
192 Problem with this is that the import() call happens after init_profiler() 192 Problem with this is that the import() call happens after init_profiler()
193 so limits the usefulness. So we'd need to limit it to certain options 193 so limits the usefulness. So we'd need to limit it to certain options
194 (trace would certainly be useful). 194 (trace would certainly be useful).
195 195
196 Add resolution of __ANON__ sub names (eg imported 'constants') where possible. 196 Add resolution of __ANON__ sub names (eg imported 'constants') where possible.
197 [I can't recall what I meant by that now. I think this means where an anon sub 197 [I can't recall what I meant by that now. I think this means where an anon sub
198 has been imported, if the refcnt is 1 then use the imported name instead of the 198 has been imported, if the refcnt is 1 then use the imported name instead of the
199 __ANON__ name.] 199 __ANON__ name.]
200 200
201 The appending of an @line to BEGIN subs should also be applied to END subs. 201 The appending of an @line to BEGIN subs should also be applied to END subs.
202 202
203 Record $AUTOLOAD when AUTOLOAD() called. Perhaps as ...::AUTOLOAD[$AUTOLOAD] 203 Record $AUTOLOAD when AUTOLOAD() called. Perhaps as ...::AUTOLOAD[$AUTOLOAD]
204 Or perhaps just use the original name if the 'resolved' one is AUTOLOAD. 204 Or perhaps just use the original name if the 'resolved' one is AUTOLOAD.
205 Could be argued either way. 205 Could be argued either way.
206 206
207 More generally, consider the problem of code where one code path is fast 207 More generally, consider the problem of code where one code path is fast
208 and just sets $sql = ... (for example) and another code path executes the 208 and just sets $sql = ... (for example) and another code path executes the
209 sql. Some $sql may be fast and others slow. The profile can't separate the 209 sql. Some $sql may be fast and others slow. The profile can't separate the
210 timings based on what was in $sql because the code path was the same in both 210 timings based on what was in $sql because the code path was the same in both
211 cases. (For sql DBI::Profile can be used, but the underlying issue is general.) 211 cases. (For sql DBI::Profile can be used, but the underlying issue is general.)
212 212
213 The sub_caller information is currently one level deep. It would be good to 213 The sub_caller information is currently one level deep. It would be good to
214 make it two levels. Especially because it would allow you to "see through" 214 make it two levels. Especially because it would allow you to "see through"
215 AUTOLOADs and other kinds of 'dispatch' subs. 215 AUTOLOADs and other kinds of 'dispatch' subs.
216 216
217 Refactor this HACKING file! 217 Refactor this HACKING file!
218 218
219 The data file includes the information mapping a line-level line to the 219 The data file includes the information mapping a line-level line to the
220 corresponding block-level and sub-level lines. This should be added to the data 220 corresponding block-level and sub-level lines. This should be added to the data
221 structure. It would enable a much richer visualization of which lines have 221 structure. It would enable a much richer visualization of which lines have
222 contributed to the 'rolled up' counts. That's especially tricky to work out 222 contributed to the 'rolled up' counts. That's especially tricky to work out
223 with the block level view. 223 with the block level view.
224 224
225 Following on from that I have a totally crazy idea that the browsers css engine 225 Following on from that I have a totally crazy idea that the browsers css engine
226 could be used to highlight the corresponding rollup line when hovering over a 226 could be used to highlight the corresponding rollup line when hovering over a
227 source line, and/or the opposite. Needs lots of thought, but it's an interesting idea. 227 source line, and/or the opposite. Needs lots of thought, but it's an interesting idea.
228 228
229 Profile and optimize report generation 229 Profile and optimize report generation
230 230
231 Bug or limitation?: sub calls in a continue { ... } block of a while () get 231 Bug or limitation?: sub calls in a continue { ... } block of a while () get
232 associated with the 'next;' within the loop. Fixed by perl change 33710? 232 associated with the 'next;' within the loop. Fixed by perl change 33710?
233 233
234 Investigate style.css problem when using --outfile=some/other/dir 234 Investigate style.css problem when using --outfile=some/other/dir
235 235
236 Sub profiler should avoid sv_setpvf(subname_sv, "%s::%s", stash_name, GvNAME(gv));
237 because it's expensive (Perl_sv_setpvf_nocontext accounts for 29% of pp_entersub_profiler).
238 Use a two level hash: HvNAME(GvSTASH(gv)) then GvNAME(gv).
239 Should then also be able to avoid newSV/free for subname_sv (which accounts for 50% of its time).
240
241 Class::MOP should update %DB::sub (if $^P & 0x10 set) when it creates methods. 236 Class::MOP should update %DB::sub (if $^P & 0x10 set) when it creates methods.
242 Sub::Name should do same (extracting the file and line from the ANON[...:...]) 237 Sub::Name should do same (extracting the file and line from the ANON[...:...])
243 238
244 Add refs so a string eval fid can be related to its 'siblings' (other string
245 eval fids from the same line in the 'parent' fid).
246
247 Profile should report _both_ the 'raw original' filename (possibly relative) 239 Profile should report _both_ the 'raw original' filename (possibly relative)
248 used by the application being profiled, plus an absolute filename determined 240 used by the application being profiled, plus an absolute filename determined
249 ASAP (to avoid problems with scripts that chdir). 241 ASAP (to avoid problems with scripts that chdir).
250 242
251 Add (very) basic nytprofhtml test (ie it runs and produces output) so we check the VERSION has been updated. 243 Add (very) basic nytprofhtml test (ie it runs and produces output) so we check the VERSION has been updated.
252 244
253 In the called by list in html: "by $subname line $line of $file" 245 In the called by list in html: "by $subname line $line of $file"
254 make the file not include the @INC portion 246 make the file not include the @INC portion
255 247
256 Monitor and report when method cache is invalidated. Watch generation number 248 Monitor and report when method cache is invalidated. Watch generation number
257 and output a tag when it changes. Report locations of changes. Highlight those 249 and output a tag when it changes. Report locations of changes. Highlight those
258 that happen after INIT phase. 250 that happen after INIT phase.
259 251
260 Fix testing of t/*.pm_x files which are currently being ignored. 252 Fix testing of t/*.pm_x files which are currently being ignored.
261 253
262 The autosplit handling doesn't address the naming of pseudo-fids from string evals 254 The autosplit handling doesn't address the naming of pseudo-fids from string evals
263 inside autoloaded subs, like "(eval 0)[test14.pm (autosplit into auto/test14/bar.al):17]" 255 inside autoloaded subs, like "(eval 0)[test14.pm (autosplit into auto/test14/bar.al):17]"
264 The 'file name' for the eval fid needs to be edited when read in to remove the 256 The 'file name' for the eval fid needs to be edited when read in to remove the
265 ' (autosplit...', but care should be taken to not remove the text for evals in 257 ' (autosplit...', but care should be taken to not remove the text for evals in
266 autosplit files for which we've not been able to alias to the parent. 258 autosplit files for which we've not been able to alias to the parent.
267 259
268 Add a FID_ATTRIB tag to allow additional info about fids to be generated after 260 Add a FID_ATTRIB tag to allow additional info about fids to be generated after
269 the initial fid info is output. 261 the initial fid info is output.
270 262
271 Use FID_ATTRIB tag to record autoload fids being aliases to a fid so that 263 Use FID_ATTRIB tag to record autoload fids being aliases to a fid so that
272 reports can include a list of autoloaded subs. 264 reports can include a list of autoloaded subs.
273 265
274 Check if pp_leavegiven and pp_leavewhen need handling in init_profiler(). 266 Check if pp_leavegiven and pp_leavewhen need handling in init_profiler().
275 267
276 Copy the nytprof.out file into the output report dir, so a report is more 268 Copy the nytprof.out file into the output report dir, so a report is more
277 'self-contained' and can be archived and thrown around as a tarball/zip and 269 'self-contained' and can be archived and thrown around as a tarball/zip and
278 still used for further analysis. 270 still used for further analysis.
279 271
280 To stress-test NYTProf using perl's own test suite, set env vars: 272 To stress-test NYTProf using perl's own test suite, set env vars:
281 NYTPROF='file=/tmp/nytprof.out:addpid=1:nameanonsubs=0:nameevals=0' 273 NYTPROF='file=/tmp/nytprof.out:addpid=1:nameanonsubs=0:nameevals=0'
282 PERL5OPT='-d:NYTProf' 274 PERL5OPT='-d:NYTProf'
283 and hack t/TEST to not delete the PERL5OPT env var. 275 and hack t/TEST to not delete the PERL5OPT env var.
284 276
285 The findcaller option doesn't notice if the caller is an opcode. 277 The findcaller option doesn't notice if the caller is an opcode.
286 Opcodes that call subs (like subst calling utf8::SWASHGET) probably shouldn't 278 Opcodes that call subs (like subst calling utf8::SWASHGET) probably shouldn't
287 appear as the caller in the call-tree because, while strictly accurate, it's 279 appear as the caller in the call-tree because, while strictly accurate, it's
288 probably less useful from the users perspective. 280 probably less useful from the users perspective.
289 Fixing that part is easy but handling incl/excl time needs more thought. 281 Fixing that part is easy but handling incl/excl time needs more thought.
290 282
291 For xsubs and opcodes that call perl subs: 283 For xsubs and opcodes that call perl subs:
292 In the subroutine prologue that currently lists where the sub was called from, 284 In the subroutine prologue that currently lists where the sub was called from,
293 for xsubs & opcodes, add a list of subs that it called (typically none). 285 for xsubs & opcodes, add a list of subs that it called (typically none).
294 That would be handy because currently calls from xsubs & opcodes appear in the 286 That would be handy because currently calls from xsubs & opcodes appear in the
295 reports at the line of the last _perl_ statement executed, and not in the fake 287 reports at the line of the last _perl_ statement executed, and not in the fake
296 'stub' that we add to the end of the package source. 288 'stub' that we add to the end of the package source.
297 289
298 Use gethrtime() on platforms that support it. 290 Use gethrtime() on platforms that support it.
299 http://developers.sun.com/solaris/articles/time_stamp.html 291 http://developers.sun.com/solaris/articles/time_stamp.html
300 http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=332 292 http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=332
301 293
302 Currently lvalue subs aren't profiled when use_db_sub is in effect. 294 Currently lvalue subs aren't profiled when use_db_sub is in effect.
303 http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2010-02/msg00824.html 295 http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2010-02/msg00824.html
304 296
305 Idle conjecture: perhaps loading the profile data into an SQLite database 297 Idle conjecture: perhaps loading the profile data into an SQLite database
306 would be a better approach to reporting. 298 would be a better approach to reporting.
307 (An nytprofimport utility could read an nytprof.out and write an nytprof.db) 299 (An nytprofimport utility could read an nytprof.out and write an nytprof.db)
308 Then, rather than hand-crafting inflexible data structures we could use SQL 300 Then, rather than hand-crafting inflexible data structures we could use SQL
309 (or, say, DBIx::Class) to return relevant data. Would also provide another 301 (or, say, DBIx::Class) to return relevant data. Would also provide another
310 route for other data sources (languages/tools) to be included in a report. 302 route for other data sources (languages/tools) to be included in a report.
311 Could also simplify: comparing profiles, merging profiles, ... 303 Could also simplify: comparing profiles, merging profiles, ...
312 Also 'pipelines' of plugin db-to-db transformations could be developed. 304 Also 'pipelines' of plugin db-to-db transformations could be developed.
313 Any volunteers to explore writing an nytprofimport for SQLite? 305 Any volunteers to explore writing an nytprofimport for SQLite?
314 306
315 Option to add sub call and return events into the data file as they happen. 307 Option to add sub call and return events into the data file as they happen.
316 Would enable a dprofpp -T like output. See https://rt.cpan.org/Ticket/Display.html?id=50766 308 Would enable a dprofpp -T like output. See https://rt.cpan.org/Ticket/Display.html?id=50766
309 Especially relevant as DProf is being removed from the code and this is
310 something NYTProf still doesn't do.
317 311
318 String evals could/should be tied into the subroutine profiler. 312 String evals could/should be tied into the subroutine profiler.
319 That would give inclusive timings which we don't have at the moment. 313 That would give inclusive timings which we don't have at the moment.
320 The evals appear in the html report as if they're calls but the timings are 314 The evals appear in the html report as if they're calls but the timings are
321 statement timings of the eval fid that don't include time spent in subs defined 315 statement timings of the eval fid that don't include time spent in subs defined
322 elsewhere but called from the string eval. The inconsistency is confusing. 316 elsewhere but called from the string eval. The inconsistency is confusing.
323 317
324 Modify csv output to optionally include extra metadata lines. Use for testing. 318 Modify csv output to optionally include extra metadata lines. Use for testing.
325 319
326 In html report where sub callers are shown (called N times by S from F at line L) 320 In html report where sub callers are shown (called N times by S from F at line L)
327 also show in compact form links to the callers of the caller, if there aren't too many. 321 also show in compact form links to the callers of the caller, if there aren't too many.
328 This makes it faster to climb the call stack. A simple mouseover will show the 322 This makes it faster to climb the call stack. A simple mouseover will show the
329 filename of the caller (perhaps a tooltip could give the file and sub). 323 filename of the caller (perhaps a tooltip could give the file and sub).
330 Also needed for modules that take shortcuts calling XS functions (*cough DBI*). 324 Also needed for modules that take shortcuts calling XS functions (*cough DBI*).
331 And/or, add a simple up arrow that'll just to the calling sub. Typically that'll 325 And/or, add a simple up arrow that'll just to the calling sub. Typically that'll
332 be the surrounding "sub foo { ..." (which'll be handy for big subs) but for 326 be the surrounding "sub foo { ..." (which'll be handy for big subs) but for
333 cases where the call to that sub wasn't recorded (eg pre 5.8.9 or the DBI's 327 cases where the call to that sub wasn't recorded (eg pre 5.8.9 or the DBI's
334 xs calling optimization) it'll be the most recent sub entry that was recorded. 328 xs calling optimization) it'll be the most recent sub entry that was recorded.
335 329
336 Generate extra report pages for xsubs in packages that don't have source code. 330 Generate extra report pages for xsubs in packages that don't have source code.
337 They're currently all dumped into the 'main' file. 331 They're currently all dumped into the 'main' file.
338 332
339 Docs describing how the subroutine profiler works need updating. 333 Docs describing how the subroutine profiler works need updating.
340 Add 'u' key to treemap to trigger moving 'up' a level. 334 Add 'u' key to treemap to trigger moving 'up' a level.
341 Add "calls N subs" to treemap mouseover box 335 Add "calls N subs" to treemap mouseover box
342 Upgrade treemap to JIT version 2 (which has transition animations). 336 Upgrade treemap to JIT version 2 (which has transition animations).
343 337
338 Sub profiler should avoid sv_setpvf(subname_sv, "%s::%s", stash_name, GvNAME(gv));
339 because it's expensive (Perl_sv_setpvf_nocontext accounts for 29% of pp_entersub_profiler).
340 Use a two level hash: HvNAME(GvSTASH(gv)) then GvNAME(gv).
341 Should then also be able to avoid newSV/free for subname_sv (which accounts for 50% of its time).
342
344 The subroutine profiler spends a lot of its time allocating the two 343 The subroutine profiler spends a lot of its time allocating the two
345 calle[rd]_subname_sv SVs in subr_entry_setup and freeing them in subr_entry_destroy. 344 calle[rd]_subname_sv SVs in subr_entry_setup and freeing them in subr_entry_destroy.
346 If, instead of freeing the SVs they were chained into a freelist that 345 If, instead of freeing the SVs they were chained into a freelist that
347 subr_entry_setup could pull from, we'd get a significant boost in performance 346 subr_entry_setup could pull from, we'd get a significant boost in performance
348 for the subroutine profiler. 347 for the subroutine profiler. It would also greatly reduce the risk of
348 NYTProf overwriting a recently freed but still on the stack SV.
349 349
350 Would be good to be able to measure the time spent in require. The easy way 350 Would be good to be able to measure the time spent in require. The easy way
351 would be to treat it as a slowop. I recall enabling this in the early days 351 would be to treat it as a slowop. I recall enabling this in the early days
352 of slowop support but running into problems. It would be good to revisit. 352 of slowop support but running into problems. It would be good to revisit.
353 This would help with profiling issues like: 353 This would help with profiling issues like:
354 http://blog.moose.perl.org/2010/08/moose-110-and-classmop-105-now-compiling-10-faster.html 354 http://blog.moose.perl.org/2010/08/moose-110-and-classmop-105-now-compiling-10-faster.html
355 355
356 We need a start=begin option to start at the _end_ of any INIT subs. 356 We need a start=runtime option to start at the _end_ of any INIT subs.
357 (The current start=init option is the closest we have but it's not very 357 (The current start=init option is the closest we have but it's not very
358 useful if lots of other work is done in INIT blocks.) 358 useful if lots of other work is done in INIT blocks.)
359 359
360 We need an option to discount the time spent in CORE:accept so that time 360 We need an option to discount the time spent in CORE:accept so that time
361 pure-perl webservers spend waiting for the next request doesn't distort the 361 pure-perl webservers spend waiting for the next request doesn't distort the
362 profile. Possibly straight-forward to implement. The trick is to add the time 362 profile. Possibly straight-forward to implement. The trick is to add the time
363 spent in the sub to the statement profiler overhead time, thus getting it 363 spent in the sub to the statement profiler overhead time, thus getting it
364 subtracted from the higher level sub time. Maybe. 364 subtracted from the higher level sub time. Maybe.
365
366
Powered by Google Project Hosting