title: Slowdown when accessing data at page boundaries?
body: <p>(My question is related to computer architecture and performance understanding. Did not find a relevant forum, so post it here as a general question.)</p>
  
  <p>I have a <code>C</code> program which accesses memory words that are located X bytes apart in virtual address space. For instance, <code>for (int i=0;&lt;some stop condition&gt;;i+=X){array[i]=4;}</code>.</p>
  
  <p>I measure the execution time with a varying value of <code>X</code>. Interestingly, when <code>X</code> is the power of <code>2</code> and is about page size, e.g., <code>X=1024,2048,4096,8192...</code>, I get to huge performance slowdown. But on all other values of <code>X</code>, like <code>1023</code> and <code>1025</code>, there is no slowdown. The performance results are attached in the figure below.</p>
  
  <p><a href="https://i.stack.imgur.com/eBrRR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eBrRR.png" alt="X axis is the value of &lt;code&gt;X&lt;/code&gt; and Y-axis is execution time in milliseconds"></a></p>
  
  <p>I test my program on several personal machines, all are running Linux with x86_64 on Intel CPU. </p>
  
  <p>What could be the cause of this slowdown? We have tried row buffer in DRAM, L3 cache, etc. which do not seem to make sense...</p>
  
  <p>Update (July 11)</p>
  
  <p>We did a little test here by adding NOP instructions to the original code. And the slowdown is still there. This sorta veto the 4k alias. The cause by conflict cache misses is more likely the case here.</p>