Page 1 of 1

A small Forth profiler

Posted: Fri Apr 16, 2021 7:24 pm
by pzembrod
Hi all,

I wanted to share a new little tool I built in the context of my cc64 development, a small profiler. It's built for C64 VolksForth and uses an extended NEXT routine that sorts NEXT invocation counts and the time spent between each NEXT iteration into one of up to 8 buckets, memory ranges in the dictionary, that can be flexibly defined to cover either large areas, whole modules or groups of modules of the program under investigation, or smaller areas down to individual words. One extra rule places time spent in the Forth core into the bucket from where the Forth core was called.

This approach gave me the overview I was looking for. I found that ~10% compiler time was spent in one single inefficient word and another ~10% in an inefficient module interface, both of which I wouldn't have guessed to be hotspots.

The core code lives here: https://github.com/pzembrod/cc64/blob/m ... ofiler.fth
And here are the reports for profiler runs over the main e2e test suite over time, with successive optimizations applied, and over different bucket groups:
https://github.com/pzembrod/cc64/tree/m ... e-register

Would this profiler be useful or interesting for anyone else?

Cheers
/Philip

Edited 2021-05-31: Changed the v0.9-dev branch links to master branch links since branch v0.9-dev is now deleted.

Re: A small Forth profiler

Posted: Fri May 21, 2021 11:27 am
by pjeaton
I'm interested in having a look, but your links don't work for me, I get GitHub 404.

Re: A small Forth profiler

Posted: Fri May 21, 2021 11:46 am
by BigEd
Check the main branch - looks like the specifically linked dev branch has been pruned.
https://github.com/pzembrod/cc64/blob/m ... ofiler.fth
https://github.com/pzembrod/cc64/tree/m ... e-register

Re: A small Forth profiler

Posted: Fri May 21, 2021 11:56 am
by pjeaton
Works now, thanks!

Re: A small Forth profiler

Posted: Mon May 31, 2021 9:00 pm
by pzembrod
BigEd wrote:
Check the main branch - looks like the specifically linked dev branch has been pruned.
Thanks, BigEd, correct, I had since merged the dev branch into master and deleted it.
I now also fixed the links in the initial post, with an "edited" note.

Re: A small Forth profiler

Posted: Mon May 31, 2021 9:03 pm
by BigEd
Great, thanks!