vendredi 27 février 2015

iOS Cache Line Optimization



I have the follow struct in C++ on iOS, and am wondering if it is a problem, performance wise. I have been reading on cache line access and minimising them for optimal performance. I understand that on iOS, the newer chips have a cache line size of 32bytes.


I have the following struct in my app.



struct globalSynthParams
{
globalVoiceParams voiceParams;
globalOscillatorParams osc1Params;
globalOscillatorParams osc2Params;
globalOscillatorParams osc3Params;
globalOscillatorParams osc4Params;
globalOscillatorParams lfo1Params;
globalOscillatorParams lfo2Params;
globalFilterParams filter1Params;
globalFilterParams filter2Params;
globalEGParams eg1Params;
globalEGParams eg2Params;
globalEGParams eg3Params;
globalEGParams eg4Params;
globalDCAParams dcaParams;
};


When I run the sizeof() for each inner struct, it gives me:



Size of globalVoiceParams: 200
Size of globalOscillatorParams: 56
Size of globalFilterParams: 24
Size of globalEGParams: 24
Size of globalDCAParams: 8
Size of globalSynthParams: 688 (the total size of the above struct)


Is this considered bad struct planning? Would there be any tangible performance improvement if I break up the structs such that they fit within a cache line or 2? I have checked the inner structs, they are packed nicely.


Many thanks for your insights.




Aucun commentaire:

Enregistrer un commentaire