Kam
Kam

Reputation: 6008

Code duplication reduces effective cache size

I'm reading a presentation from Scott Mayor, he mentiones this line:

Down side of inlining: Code duplication reduces effective cache size

I am not seeing how code duplication has anything to do with effective cache size

Upvotes: 2

Views: 69

Answers (1)

mcleod_ideafix
mcleod_ideafix

Reputation: 11438

Duplicating code means that the same instructions are duplicated on consecutive memory addresses instead of having one single copy of those instructions in the body of a loop. That means that many cache lines are filled with the same content instead of just a few. As those instructions are frequently accessed (once per loop run) they are likely not leaving the cache, so other code (or data if cache is unified) must leave, which wouldn't happen if there were less number of frequently accessed instructions filling cache entries.

Upvotes: 5

Related Questions