chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

A profiler for Chibi?

Open kozross opened this issue 8 years ago • 2 comments

This is less an issue and more 'would be lovely to have, if you could'. Have there been any previous plans for such? What would realistically need to be done to have a profiler for Chibi?

kozross avatar Jan 25 '17 06:01 kozross

Not really - performance has never been a priority for Chibi.

There are two general approaches to profiling: 1) instrumenting and timing all (or some subset of) procedure applications, or 2) sampling snapshots of the stack to see what procedure calls are active. The former could be done purely in Scheme but the overhead might be large enough to distort results. Either could be done easily enough in C, but I'd do this as a compile-time option, storing the data in the procedure struct. Implementation should be trivial, with most work going into displaying and analyzing the results.

ashinn avatar Jan 29 '17 14:01 ashinn

The (chibi optimize profile) module gives counts (not times) for called procedures. If you have a script you run as:

chibi-scheme foo.scm

you can print the profile with

chibi-scheme -mchibi.optimize.profile -l foo.scm -e'(profile-report)'

This does slow down execution considerably enough that I'm not sure adding times would be much more help. A sampling profiler might be better in that case.

ashinn avatar Aug 25 '20 05:08 ashinn