A small Forth profiler

Topics relating to various Forth models on the 6502, 65816, and related microprocessors and microcontrollers.
Post Reply
pzembrod
Posts: 22
Joined: 05 Sep 2020
Contact:

A small Forth profiler

Post 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.
Last edited by pzembrod on Mon May 31, 2021 8:58 pm, edited 1 time in total.
User avatar
pjeaton
Posts: 23
Joined: 23 Feb 2005
Location: Zurich, Switzerland

Re: A small Forth profiler

Post by pjeaton »

I'm interested in having a look, but your links don't work for me, I get GitHub 404.
P*h*i*l*l*i*p EEaattoon in real life
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: A small Forth profiler

Post 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
User avatar
pjeaton
Posts: 23
Joined: 23 Feb 2005
Location: Zurich, Switzerland

Re: A small Forth profiler

Post by pjeaton »

Works now, thanks!
P*h*i*l*l*i*p EEaattoon in real life
pzembrod
Posts: 22
Joined: 05 Sep 2020
Contact:

Re: A small Forth profiler

Post 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.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: A small Forth profiler

Post by BigEd »

Great, thanks!
Post Reply