degraded performance with cpu-quota and hyper-threading
- [X] This is a bug report
- [ ] This is a feature request
- [X] I searched existing issues before opening this one
Expected behavior
--cpu-quota 200000 --cpu-period 100000 should limit the container to the same speed regardless of the number of threads doing the work.
Actual behavior
When there are more threads than real cores the performance decreases considerably. Detailed examples and scripts to duplicate the result are there: https://github.com/sezuan/cpu-quota-vs-ht
Steps to reproduce the behavior
The test is prepared for a 4 core / 8 ht CPU.
- Build docker image using https://github.com/sezuan/cpu-quota-vs-ht
- Run
test_no_limit.sh - Run
test_2cpu_limit.sh - Disable hyper-threading
- Run
test_2cpu_limit.sh - Notice performance impact when the thread number is greater than the number of real cores.
My educated^Wwild guess is, that this might be caused by the way the CPU quota works. All threads will use all 8 cores, including the 4 hyper-threading cores (which are useless in this case). Then the threads are paused till the container's usage will be 2 cores. But these 2 cores are actually 1 real core, so the performance will be the half of the configured and expected performance.
Output of docker version:
Docker version 18.06.1-ce, build e68fc7a
Output of docker info:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 45
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.0-8-amd64
Operating System: Debian GNU/Linux 9 (stretch)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.61GiB
Name: DXKA-64M0202
ID: 5WU7:SMSA:EEQK:RSTW:6VGB:LMET:IZKB:C2IQ:PKCD:MZUV:VH47:7JM3
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://docker.mamdev.server.lan/
Live Restore Enabled: false
WARNING: No swap limit support
I'm experiencing a similar issue, in which increasing the host capabilities while maintaining the CPU limits in the container affects the performance of the container.
I took some measurings of the app startup for guidance, but the overall app performance is affected. (check attached image)
It seems to only happen when using CentOS on the host and not Ubuntu. On Ubuntu the times are exactly what we'd expect. I'm am not comparing times across hosts, because I cannot guarantee exactly the same physical hardware. My concern here is the degradation when adding CPUs to the host. This should not happen.
Docker info (CentOS host):
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.11.6.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 31.26GiB
Name: ReleaseDocker2.dev.omitted
ID: I33O:N4O6:6BM2:H3XZ:SDFO:4UGO:AD2L:OSAC:NWGH:UBBH:WMWH:GXED
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: true
Docker info (Ubuntu Host):
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 18.03.1-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 18
Dirperm1 Supported: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
apparmor
Kernel Version: 3.13.0-34-generic
Operating System: Ubuntu 14.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 31.42GiB
Name: ReleaseDocker1
ID: 62Q4:27AD:CQ2K:J6WC:LOGR:L3YO:YGDZ:OM54:KTWK:VW7D:FW7I:AAPH
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: true
WARNING: No swap limit support