Issue 617311: Tiny profiling info (Psyco #2) (original) (raw)

Created on 2002-10-01 23:20 by arigo, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff-2.2 arigo,2002-10-01 23:20 context diff against the 2.2 branch
diff-2.3 arigo,2002-10-07 14:17 context diff for the cvs trunk
diff arigo,2002-10-09 13:20 updated context diff for 2.3
Messages (8)
msg41287 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2002-10-01 23:20
Psyco-friendly patch #2. A very very small statistic-collecting patch. pystate.h: added a field at the end of the PyThreadStruct: int tick_counter; ceval.c: eval_frame(): tstate->tick_counter is incremented whenever the check_interval ticker reaches zero. The purpose is to give a useful measure of the number of interpreted bytecode instructions in a given thread. This extremely lightweight statistic collector can be of interest to profilers (like psyco.jit()). We can safely guess that a single integer increment every 100 interpreted bytecode instructions will go entierely unnoticed in any performance measure. [This is true for pystone.py.]
msg41288 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-10-04 10:42
Logged In: YES user_id=6656 I see no harm in this. Are you sure it's actually going to be useful, though?
msg41289 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2002-10-04 14:36
Logged In: YES user_id=4771 It is the only way I could work out so far that can "predict" how much a function will be accelerated when run under Psyco. This is a very precious indication for an automatic Psyco-binder. The following table shows the results with the various test functions of the distribution's "test.py" file: (fn name) (speed-up) (bytecode insns per second) f1 106.00 2310545 f4 11.33 2819100 f5 12.08 2992445 f6 1.35 412022 f7 2.24 1331353 f7bis 10.29 1632296 The third column is '(tick_counter * check_interval) / execution_time'. The correlation between the two columns is admittedly not perfect, but still we can see that it was not worthy to try and accelerate f6 because it didn't spend a lot of time actually interpreting bytecodes. Note that similar information could be obtained by setting a line-tracing hook, counting not instructions but lines (which is less precise but still a good approximation). However, line tracing is *much* too slow for anything but debugging usage.
msg41290 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-10-06 20:45
Logged In: YES user_id=6380 I'd like to get this into 2.2.2. MWH, can you check it in?
msg41291 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-10-07 09:42
Logged In: YES user_id=6656 Done in Include/pystate.h revision 2.18.16.1 Python/ceval.c revision 2.301.4.7 Armin, I don't know how you generated this patch, but it would have been easier to apply if it had been rooted in the "src" directory, like e.g.: $ cvs diff Include/pystate.h Python/ceval.c > ~/diff
msg41292 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2002-10-07 14:17
Logged In: YES user_id=4771 Uploaded the 2.3 patch (this one cleanly generated -- for the other one I just cat'ed two patches in one).
msg41293 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2002-10-09 13:20
Logged In: YES user_id=4771 Attached an updated diff for 2.3. This one doesn't have Windows line endings and includes the initialization of tick_counter to 0 that was added by Guido in the latest 2.2.2. (I thought it was unnecessary to initialize it to anything because profilers would only be interested in differences.)
msg41294 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-11-08 12:56
Logged In: YES user_id=6656 I got lazy and checked in all the psyco patches at once: Include/pystate.h revision 2.21 Modules/pyexpat.c revision 2.76 Python/ceval.c revision 2.340 Python/pystate.c revision 2.22
History
Date User Action Args
2022-04-10 16:05:43 admin set github: 37246
2002-10-01 23:20:54 arigo create