Memory benchmarks – writes
April 13, 2016 Leave a comment
All the benchmarks executed so far performed only read operations. So, what about write performance, will they be as fast as reads? In the case of writes we will only be interested in sequential and random reads. The code is almost identical to the one used for the read benchmarks, but instead of reading the value from the array, I write the value of the current index:
for (int i = 0; i < steps; i++) array[(11587L*i) & mask] = i;
and
for (int i = 0; i < steps; i++) array[i] = i;
To facilitate the comparison between reads and writes I included the results of the read benchmarks. For sequential access, we have:
Where we see that single and dual threaded sequential write bandwidth is identical to read bandwidth, but for a larger number of threads these two diverge with the write bandwidth saturating at about 20 GB/s, while the read bandwidth reaches 40 GB/s with six threads.
For random access there is much less difference between the two cases:
Note that for both benchmarks a single 1 GB array of longs is accessed by all threads. In terms of access time or frequency we are speaking of 18 ns and 56 MHz.
Remember that these results are specific to C# on .Net, better performance is expected from e.g. C++ code or .Net native. It would be worth reproducing the sequential writes benchmark in C++ or in Java to confirm that we are not hitting a .Net bottleneck.
The code is available on Github.