Why is copying memory slow on EC2 computers?

The copies of memory on my EC2 machine are surprisingly slow. I would like to know why.

On most computers, I observe a memory bandwidth of 3,000 MB / s. See the following Python snippet:

In [1]: data = b'0' * int(1e8)  # 100 MB

In [2]: %time len(data[1:])     # memcopy
CPU times: user 18.4 ms, sys: 8.62 ms, total: 27.1 ms
Wall time: 27.1 ms
Out[2]: 99999999

In [3]: 100000000 / 0.027 / 1e6  # MB/s
Out[3]: 3703.703703703704

However, on EC2 this changes significantly

In [1]: data = b'0' * int(1e8)  # 100 MB

In [2]: %time len(data[1:])     # memcopy
CPU times: user 44 ms, sys: 148 ms, total: 192 ms
Wall time: 192 ms
Out[2]: 99999999

In [3]: 100000000 / 0.192 / 1e6  # MB/s
Out[3]: 520.8333333333333

I have never seen memcpy run this before. What is the probable cause?

Customization

The software environments are basically the same. I am running Ubuntu 14.04 and Anaconda with Python 2.7 on each machine. The hardware is different

  • Notebook (Thinkpad w540): Intel (R) Core (TM) i7-4700MQ CPU @ 2.40 GHz
  • EC2 machine (m4.xlarge): Intel (R) Xeon (R) CPU E5-2670 v2 @ 2.50 GHz
+4
source share

All Articles