Re: GCC version VS performance
Posted: Sun Jun 11, 2017 9:53 pm
Ok, i think i got it working right now, with a single bin folder
After some tests i can say the new GCC 6.3 can perform much better in some case (when you are calling many time a small method for instance where the previous GCC 3.4.6 was not able to inline it) and generally perform better than GCC 3.4.6.
On the SGDK benchmark tests i observed a score increase from ~18000 to ~21000 in total score. But i was using -O1 with GCC 3.4.6 while i'm using -03 and others extra optimization flags with GCC 6.3 so at the end, the difference is not that important. I even observed some cases where GCC 3.4.6 was a bit faster (with -O1) but only by a very small margin... SGDK is also already using assembly for some critical parts and i always tried to profile slow parts of the library and tried to help the compiler to produce the best code so this result is not that surprising.
I still believe that for a full C project the performance difference can be much more important (20% up to 50% faster in best case), I am confident it will help for the sprite engine which is still done in 100% C code
I had to fix some stuff in the lib to get it working correctly :
- put vtimer as 'volatile' (this is expected, it should have been volatile from beginning)
- increasing the default Stack size from 0x400 to 0x800 as newer optimizations tend to consume much more stack memory...
this one was tricky to figure (stack overwriting part of heap memory which create all sort of weird bugs).
So the next SGDK will definitely use the new GCC 6.3 ! Thanks again Gligli for your big contribution here =) I was even able to reduce a bit the size of required files so the bin folder size is about 43 MB for GCC 6.3 compared to previous 26 MB for GCC 3.4.6, definitely not as much as i was expecting
One minor bad news is that despite my efforts i couldn't get GDB working with BlastEm nor GensKmod, i obtains different errors on both emulators... I think the problem is on emulator side, probably not compatible with GDB 7.12
After some tests i can say the new GCC 6.3 can perform much better in some case (when you are calling many time a small method for instance where the previous GCC 3.4.6 was not able to inline it) and generally perform better than GCC 3.4.6.
On the SGDK benchmark tests i observed a score increase from ~18000 to ~21000 in total score. But i was using -O1 with GCC 3.4.6 while i'm using -03 and others extra optimization flags with GCC 6.3 so at the end, the difference is not that important. I even observed some cases where GCC 3.4.6 was a bit faster (with -O1) but only by a very small margin... SGDK is also already using assembly for some critical parts and i always tried to profile slow parts of the library and tried to help the compiler to produce the best code so this result is not that surprising.
I still believe that for a full C project the performance difference can be much more important (20% up to 50% faster in best case), I am confident it will help for the sprite engine which is still done in 100% C code
I had to fix some stuff in the lib to get it working correctly :
- put vtimer as 'volatile' (this is expected, it should have been volatile from beginning)
- increasing the default Stack size from 0x400 to 0x800 as newer optimizations tend to consume much more stack memory...
this one was tricky to figure (stack overwriting part of heap memory which create all sort of weird bugs).
So the next SGDK will definitely use the new GCC 6.3 ! Thanks again Gligli for your big contribution here =) I was even able to reduce a bit the size of required files so the bin folder size is about 43 MB for GCC 6.3 compared to previous 26 MB for GCC 3.4.6, definitely not as much as i was expecting
One minor bad news is that despite my efforts i couldn't get GDB working with BlastEm nor GensKmod, i obtains different errors on both emulators... I think the problem is on emulator side, probably not compatible with GDB 7.12