Keeping your code in L1 cache

空扰寡人 提交于 2019-12-03 07:45:34

I think what they're saying is not that the entire program fits in L1 cache, but that all the code that runs most of the time fits in the L1 cache.

Yes, the OS allocates lots of other structures, but those are hit rarely enough to not matter.

Of course, this is all speculation -- I know nothing about the 'K' language.

I believe they are speaking to the advantage that the main executing code will fit in the L1 cache; regardless of the memory allocated to the program. Once the K application is loaded, if it never touches that memory then it doesn't matter if it's allocated in terms of performance (i.e. the perf benefit of being totally in L1 cache).

sharptooth

You confuse all the program code with the most frequently executed code.

For the interpreted languages the interpreter core is certainly among the most frequently executed code. Having most frequently executed code in cache speeds up execution the same way as having most frequently accessed data in cache does.

The key part is "most frequently" - it's not necessary to have all the code/data cached to see a significant acceleration.

The interpreter runs as a normal program managed by the OS. The interpreted program runs within the memory space of the interpreter, in the data segment. Many K programs may easily fit into the L1 cache completely, even though the entire interpreter may not. The main interpreter loop will probably fit though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!