Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Function sizes

This topic is 6170 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!