Python OS X 与 Ubuntu 上的异步性能
Python asyncio performance on OS X vs Ubuntu
我在 OS X 上的 Python asyncio 性能有一些问题。我有 Macbook pro 2015 和 16gb 内存。但是无法在 OS X (El Capitan) 上获得与在 Ubuntu 上相同的性能。即使考虑到我在 运行 宁 Ubuntu 虚拟机(流浪者,4GB RAM)和 OS X 主机。
OS 使用 wrk 的 X 基准测试:
wrk -t8 -d 10s -c 300 http://127.0.0.1:9090 ⏎
Running 10s test @ http://127.0.0.1:9090
8 threads and 300 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 628.63us 1.45ms 16.32ms 89.46%
Req/Sec 696.05 834.65 5.51k 88.89%
19498 requests in 10.08s, 361.78KB read
Socket errors: connect 0, read 20482, write 0, timeout 0
Requests/sec: 1934.40
Transfer/sec: 35.89KB
Ubuntu:
wrk -t8 -d 10s -c 300 http://127.0.0.1:9090
Running 10s test @ http://127.0.0.1:9090
8 threads and 300 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.49ms 14.33ms 408.97ms 99.22%
Req/Sec 3.58k 1.41k 8.42k 70.91%
204333 requests in 10.06s, 3.70MB read
Socket errors: connect 0, read 3, write 977, timeout 0
Requests/sec: 20311.64
Transfer/sec: 376.88KB
服务器代码:https://gist.github.com/ssbb/5f6c2c043880e0e917c3254d06c52a7e
ulimit -a
在 Ubuntu 上:https://gist.github.com/ssbb/e468b3ede5470da25699e4da4506b77c
ulimit -a
在 OS X: https://gist.github.com/ssbb/f2a846975069a1d62a313790ad8d26ce
sysctl -a
在 OS X: https://gist.github.com/ssbb/c78d5da7ae9e3670175f643309cf9f6b
sysctl -a
在 Ubuntu 上:https://gist.github.com/ssbb/9a00cc3856135369b16ddc0083d2bc88
为什么我在 Ubuntu/OS X 之间有如此大的差异。我还尝试 运行 Arch Linux 上的这个服务器(不是 VM,只是第二个 OS)和结果与 OS X.
相同
Ubuntu 有一些 "hacks" 用于 TCP 堆栈吗?
MacOSX 的网络堆栈实现比 linux 慢,这是众所周知的事实。
我不知道为什么 Arch Linux 在您的机器上比 Ubuntu 慢。网络堆栈由 linux 内核本身实现,具有相同内核版本的 linux 发行版应该显示几乎相同的性能。
我在 OS X 上的 Python asyncio 性能有一些问题。我有 Macbook pro 2015 和 16gb 内存。但是无法在 OS X (El Capitan) 上获得与在 Ubuntu 上相同的性能。即使考虑到我在 运行 宁 Ubuntu 虚拟机(流浪者,4GB RAM)和 OS X 主机。
OS 使用 wrk 的 X 基准测试:
wrk -t8 -d 10s -c 300 http://127.0.0.1:9090 ⏎
Running 10s test @ http://127.0.0.1:9090
8 threads and 300 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 628.63us 1.45ms 16.32ms 89.46%
Req/Sec 696.05 834.65 5.51k 88.89%
19498 requests in 10.08s, 361.78KB read
Socket errors: connect 0, read 20482, write 0, timeout 0
Requests/sec: 1934.40
Transfer/sec: 35.89KB
Ubuntu:
wrk -t8 -d 10s -c 300 http://127.0.0.1:9090
Running 10s test @ http://127.0.0.1:9090
8 threads and 300 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.49ms 14.33ms 408.97ms 99.22%
Req/Sec 3.58k 1.41k 8.42k 70.91%
204333 requests in 10.06s, 3.70MB read
Socket errors: connect 0, read 3, write 977, timeout 0
Requests/sec: 20311.64
Transfer/sec: 376.88KB
服务器代码:https://gist.github.com/ssbb/5f6c2c043880e0e917c3254d06c52a7e
ulimit -a
在 Ubuntu 上:https://gist.github.com/ssbb/e468b3ede5470da25699e4da4506b77c
ulimit -a
在 OS X: https://gist.github.com/ssbb/f2a846975069a1d62a313790ad8d26ce
sysctl -a
在 OS X: https://gist.github.com/ssbb/c78d5da7ae9e3670175f643309cf9f6b
sysctl -a
在 Ubuntu 上:https://gist.github.com/ssbb/9a00cc3856135369b16ddc0083d2bc88
为什么我在 Ubuntu/OS X 之间有如此大的差异。我还尝试 运行 Arch Linux 上的这个服务器(不是 VM,只是第二个 OS)和结果与 OS X.
相同Ubuntu 有一些 "hacks" 用于 TCP 堆栈吗?
MacOSX 的网络堆栈实现比 linux 慢,这是众所周知的事实。
我不知道为什么 Arch Linux 在您的机器上比 Ubuntu 慢。网络堆栈由 linux 内核本身实现,具有相同内核版本的 linux 发行版应该显示几乎相同的性能。