[fpc-pascal] for loops performance problems?

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Tue Jul 4 11:26:23 CEST 2017


Hi,

On Tue, 4 Jul 2017, Anthony Walter wrote:

> I think the code to generate the geometry each frame isn't that complex,
> and I pre-allocate room in my buffer for all the geometry just once, so
> it seems doing to calculations for the geometry is what's killing the
> performance. The calculations are simple multiplication of "Single"
> type, and I am thinking maybe the "for looping" part is what's degrading
> performance. 
>
> Here is the gist of the loop that generates the text vertex buffer:
>
> https://gist.github.com/sysrpl/8af6e5a9d62cc2f2a1c40f9a9ae13b64

Well, first, please provide a compilable and runnable example for further
investigation.

> I can convert to static buffers and get good performance (if I know the
> text isn't changing), but I'm now curious if this specific performance
> issue is related to fpc's for loop code generation. 

No, it's probably the fact that you're doing 10 function calls per glyph
setup in the "World." part of your for loop, each involving their own set
of register/save restore, etc. I'd say that's probably much slower than
any performance degratation which might arise from the fact that fpc
doesn't do SSA in for loops.

But because the example you provided is not compilable, I cannot give
further hints, and the above is just speculation.

Charlie


More information about the fpc-pascal mailing list