Function sizes
Does anyone know in general, how large a function can become before it is too large to fit into a CPU''s instruction cache? Also, what is the best size range to keep functions within to increase their chances of being placed into the instruction cache. I know that any frequently used functions are more likely to be placed into cache so would it be best to keep these functions as small as possible?
Thanks
Well, obviously, it depends on the I-cache size, but, it''s not "functions" that get put into the cache, it''s usually just a hunk of memory. So, it shouldn''t be functions you''re worried about, but rather, how and where you''re functions are aligned in memory.
Let''s say you have 5 functions, but only 2 are used extensively. if you''re really worried about making sure the I-Cache isn''t clear when executing one function, then another, you''d place those two functions right next to each other in the memory map; that way, when the code is built and run, the hunk of memory that gets included into the Cache would include both functions.
My sensible answer is, don''t worry about keeping you''re code in the Cache. If you''re alogrithm is too slow, then you should improve it; it''s not the CPU''s fault.
Let''s say you have 5 functions, but only 2 are used extensively. if you''re really worried about making sure the I-Cache isn''t clear when executing one function, then another, you''d place those two functions right next to each other in the memory map; that way, when the code is built and run, the hunk of memory that gets included into the Cache would include both functions.
My sensible answer is, don''t worry about keeping you''re code in the Cache. If you''re alogrithm is too slow, then you should improve it; it''s not the CPU''s fault.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement