朋友们 我想研究一下操作系统造成的缓存污染对应用程序性能的影响。
为此,我编写了一个小型自定义基准程序。
1. malloc an array of size = l1 data cache-size
2. repeat ... sweep this array from start to end (hit-rate = 1.0)
3. *** perform a system call that thrashes l1 data cache ***
4. sweep the array once again (expected hit-rate = ~0.7 ---> 1.0)
算法的第 2 步重复读取完整的数组。希望该数组将保留在缓存中,从而导致命中率为 1。
执行系统调用后,我再次尝试读取缓存。但我假设操作系统已经驱逐了一些属于用户的缓存行。
如您所见,该程序依赖系统调用从 l1 数据缓存中逐出许多用户数据行。我怎样才能做到这一点?
我假设系统调用应该与文件相关或与流相关。