You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduced performance while building on bind mount outside of docker #2891
Host and Guest: 12.04.3
Docker: 0.6.6
lxc: 0.7.5
Kernel: 3.8.0-29
Hardware: Dual 6C Xeon with 64GB RAM and 100GB root SSD and dual 3TB RAID0
Docker is installed on the SSD using deb packages.
I created a docker image based off the base ubuntu in the registry. This image is located in /var/lib/docker on the SSD. I created a world writable directory on the RAID0 drive and bind mounted into the docker image. All the source code and builds were done in the bind mounted directory on RAID0 drive. I launched /bin/bash inside the container and then ran the build.
Builds not using docker on RAID0 take 30-40 minutes. Inside docker the builds on RAID0 bind mount were consistently 55-65 minutes (not at the same time of course).
I then ran 'docker export' and placed rootfs on RAID0 drive. I copied most of lxc config from docker and ran lxc directly using lxc-start. The build directory was again bind mounted into the lxc container. The build using lxc directly completed in 32 min. In docker and lxc the bind mount has the same options: rw,relatime,data=ordered.
I then tried docker again and bind mounted host /tmp to a container /tmp. I did the same with /var/tmp because docker diff showed changes on /var/tmp. No change in build times.
I don't know what is going on here. The rootfs is essentially read only and on ssd. I would expect the aufs overhead only when writing, not when reading. It seems that if the rootfs is aufs, a build on a mount outside of the aufs filesystem is still affected.
If there is some option/configuration I missed let me know, otherwise I will wait until the device-mapper implementation is ready and try again.
FROM ubuntu
# host packages needed to build Wind River Linux
RUN apt-get install -y libc6:i386 libc6-dev-i386 libncurses5:i386 texi2html chrpath diffstat subversion libgl1-mesa-dev libglu1-mesa-dev libsdl1.2-dev texinfo gawk gcc help2man g++ git-core python-gtk2 bash xz-utils screen make bzip2 wget
# wrlinux repos will be mounted here
RUN mkdir /buildarea
#Clean up
RUN apt-get clean
#add user for building wrlinux
RUN useradd --home-dir /home/wrlinux --uid 1000 --gid 100 --shell /bin/bash wrlinux
I will work tomorrow to add instructions for doing an oe-core build in docker.
The container is not using a memory control group. The command I used to run docker was:
Here is the lxc config I mostly copied from docker:
lxc.utsname = wrlinux
lxc.network.type=veth
lxc.network.link=lxcbr0
lxc.network.flags=up
lxc.network.name = eth0
lxc.network.mtu = 1500
lxc.network.ipv4 = 10.0.3.1/24
#lxc.mount.auto = proc sys cgroup
lxc.mount.entry=/buildarea/lxc_test /buildarea/ubuntu/buildarea none bind 0 0
lxc.cap.drop=sys_admin
lxc.rootfs=/buildarea/ubuntu
# use a dedicated pts for the container (and limit the number of pseudo terminal
# available)
lxc.pts = 1024
# disable the main console
lxc.console = none
# no controlling tty at all
lxc.tty = 1
# no implicit access to devices
lxc.cgroup.devices.deny = a
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/urandom,/dev/random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
# /dev/pts/ - pts namespaces are "coming soon"
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# tuntap
lxc.cgroup.devices.allow = c 10:200 rwm
lxc.mount.entry = proc /buildarea/ubuntu/proc proc nosuid,nodev,noexec 0 0
# WARNING: sysfs is a known attack vector and should probably be disabled
# if your userspace allows it. eg. see http://bit.ly/T9CkqJ
lxc.mount.entry = sysfs /buildarea/ubuntu/sys sysfs nosuid,nodev,noexec 0 0
lxc.mount.entry = devpts /buildarea/ubuntu/dev/pts devpts newinstance,ptmxmode=0666,nosuid,noexec 0 0
lxc.mount.entry = shm /buildarea/ubuntu/dev/shm tmpfs size=65536k,nosuid,nodev,noexec 0 0
# In order to get a working DNS environment, mount bind (ro) the host's /etc/resolv.conf into the contai
ner
lxc.mount.entry = /etc/resolv.conf /buildarea/ubuntu/etc/resolv.conf none bind,ro 0 0
I have been experimenting with Docker 0.7 and the different storage backends. The sequence was the same for all builds: docker build with same Docker file as above, docker run to bind mounted directory outside of image.
Here are some numbers:
Bare metal
real 33m3.548s
user 299m50.192s
sys 48m52.308s
docker -s vfs
real 37m33.114s
user 300m59.356s
sys 62m55.564s
docker -s aufs
real 58m9.734s
user 303m34.700s
sys 115m32.624s
docker -s devicemapper
real 34m42.002s
user 303m28.084s
sys 60m45.988s
I will now work on some instructions to do a yocto build which will allow hopefully you to reproduce locally.
To be able to do multiple builds in docker and outside of docker
without waiting for packages to download, the conf/local.conf file
needs to updated. Here are the edits that I made
Also seeing very slow access to bind-mounted volumes. Stock docker image on vagrant + default storage, Linux precise64 3.8.0-35-generic #50~precise1-Ubuntu SMP Wed Dec 4 17:25:51 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux.
No I have not tested the btrfs backend. It did not exist when I did my initial
benchmarking. I should probably redo all the tests now with updated docker and
kernel and give btrfs a try as well.
There is no need to set the parallel packages and jobs now in
local.conf because bitbake now chooses reasonable defaults.
Bare Metal:
real 29m59.190s
user 278m0.988s
sys 59m47.379s
Devicemapper:
real 32m21.074s
user 281m53.994s
sys 68m45.554s
AUFS:
real 37m14.612s
user 259m19.226s
sys 85m50.269s
I only ran each build once so this is not an authoritative
benchmark. It shows that there is a performance overhead of approx 20% when using the
aufs backend even if the IO is done on a bind mount.
@kscherer Docker 1.6 will have direct io support for aufs and it should be faster. How did you set up devicemapper? I'm asking about devicemapper because I know some people are using it in production, but the way it's set up matters.
That is good news and I look forward to rerunning my tests with 1.6.
I am using the devicemapper backend in loopback mode. This has been
working well enough, although the instance creation fails sometimes
(Issue #4096). I will look into the devicemapper direct-lvm mode and the lvm sync support
The performance of the aufs backend in this scenario has improved, but the overhead is still significant. With the udev sync requirements for devicemapper on docker 1.7, it is clear to me that overlayfs is my best option on Ubuntu now.
Since I now have two options for storage backends with acceptable performance, there isn't much point to keeping the issue open.
Activity
jpetazzo commentedon Nov 26, 2013
kscherer commentedon Nov 27, 2013
Here is the Dockerfile I used:
I will work tomorrow to add instructions for doing an oe-core build in docker.
The container is not using a memory control group. The command I used to run docker was:
Here is the lxc config I mostly copied from docker:
kscherer commentedon Dec 3, 2013
I have been experimenting with Docker 0.7 and the different storage backends. The sequence was the same for all builds: docker build with same Docker file as above, docker run to bind mounted directory outside of image.
Here are some numbers:
Bare metal
real 33m3.548s
user 299m50.192s
sys 48m52.308s
docker -s vfs
real 37m33.114s
user 300m59.356s
sys 62m55.564s
docker -s aufs
real 58m9.734s
user 303m34.700s
sys 115m32.624s
docker -s devicemapper
real 34m42.002s
user 303m28.084s
sys 60m45.988s
I will now work on some instructions to do a yocto build which will allow hopefully you to reproduce locally.
Thank you for your time and a great tool.
kscherer commentedon Dec 10, 2013
Instructions to build oe-core in docker to test build performance
Download latest poky release
To be able to do multiple builds in docker and outside of docker
without waiting for packages to download, the conf/local.conf file
needs to updated. Here are the edits that I made
To avoid messing up benchmark with downloads, do a fetchall to grab
all the needed packages from the Internet.
To do the actual build
To do the build again
On bare-metal on my machine I had the following result:
Using device-mapper
Using aufs
I would be interested to see if others can reproduce this on their hardware.
Thanks again for docker!
SvenDowideit commentedon Dec 11, 2013
@kscherer go on, blog your work! - I'm very curious too, if i get time.... :)
timruffles commentedon Jan 13, 2014
Also seeing very slow access to bind-mounted volumes. Stock docker image on vagrant + default storage,
Linux precise64 3.8.0-35-generic #50~precise1-Ubuntu SMP Wed Dec 4 17:25:51 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux.unclejack commentedon May 14, 2014
@kscherer Have you tested the btrfs storage backend?
kscherer commentedon May 14, 2014
No I have not tested the btrfs backend. It did not exist when I did my initial
benchmarking. I should probably redo all the tests now with updated docker and
kernel and give btrfs a try as well.
jessfraz commentedon Feb 25, 2015
can you see if this is a still an issue with the latest version of docker
kscherer commentedon Mar 3, 2015
Docker 1.5 on Ubuntu 14.04 with 3.16 utopic LTS kernel.
The current stable poky release is dizzy:
There is no need to set the parallel packages and jobs now in
local.conf because bitbake now chooses reasonable defaults.
Bare Metal:
Devicemapper:
AUFS:
I only ran each build once so this is not an authoritative
benchmark. It shows that there is a performance overhead of approx 20% when using the
aufs backend even if the IO is done on a bind mount.
unclejack commentedon Apr 6, 2015
@kscherer Docker 1.6 will have direct io support for aufs and it should be faster. How did you set up devicemapper? I'm asking about devicemapper because I know some people are using it in production, but the way it's set up matters.
kscherer commentedon Apr 7, 2015
That is good news and I look forward to rerunning my tests with 1.6.
I am using the devicemapper backend in loopback mode. This has been
working well enough, although the instance creation fails sometimes
(Issue #4096). I will look into the devicemapper direct-lvm mode and the lvm sync support
kscherer commentedon Jul 10, 2015
Update for Docker 1.7
Building poky, fido release, core-image-minimal on a ext4 bind mount with the docker
image using different storage backends.
Bare-metal:
Aufs:
Devicemapper with official binary in loopback mode:
Devicemapper with my own compiled dynamic binary:
Overlayfs:
See http://kscherer.github.io/docker/2015/07/09/benchmarking-docker-storage-backends/ for the Dockerfile used.
The performance of the aufs backend in this scenario has improved, but the overhead is still significant. With the udev sync requirements for devicemapper on docker 1.7, it is clear to me that overlayfs is my best option on Ubuntu now.
Since I now have two options for storage backends with acceptable performance, there isn't much point to keeping the issue open.
Thanks again for the amazing work on Docker!