Skip to content

Reduced performance while building on bind mount outside of docker #2891

Closed

Description

@kscherer

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.

Thanks for a great tool.

Activity

  1. jpetazzo commented on Nov 26, 2013

    @jpetazzo
    Contributor
    • can you describe how to reproduce the build (if that's not too complicated)? A Dockerfile would be a good start.
    • are you using the memory control group?
    • devicemapper (0.7) is here if you want to try it :-)
  2. kscherer commented on Nov 27, 2013

    @kscherer
    Author

    Here is the Dockerfile I used:

    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:

    sudo docker run -i -t -u 1000 -v /buildarea/lxc_test:/buildarea kscherer/wrlinux /bin/bash
    

    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
    
  3. kscherer commented on Dec 3, 2013

    @kscherer
    Author

    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.

  4. kscherer commented on Dec 10, 2013

    @kscherer
    Author

    Instructions to build oe-core in docker to test build performance

    Download latest poky release

    cd <buildarea>
    mkdir downloads
    chmod 777 downloads
    git clone git://git.yoctoproject.org/poky
    source poky/oe-init-build-env mybuild
    

    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

    BB_NUMBER_THREADS ?= "10"
    PARALLEL_MAKE ?= "-j 10"
    DL_DIR ?= "<buildarea>/downloads"
    

    To avoid messing up benchmark with downloads, do a fetchall to grab
    all the needed packages from the Internet.

    bitbake -c fetchall core-image-minimal
    

    To do the actual build

    time bitbake core-image-minimal
    

    To do the build again

    cd <buildarea>
    source poky/oe-init-build-env mybuild2
    cp <buildarea>/mybuild/conf/local.conf conf/local.conf
    time bitbake core-image-minimal
    

    On bare-metal on my machine I had the following result:

    real    26m53.844s
    user    225m2.560s
    sys     30m47.692s
    

    Using device-mapper

    real    30m32.703s
    user    233m52.240s
    sys     37m6.480s
    

    Using aufs

    real    40m32.032s
    user    232m22.900s
    sys     59m29.368s
    

    I would be interested to see if others can reproduce this on their hardware.

    Thanks again for docker!

  5. SvenDowideit commented on Dec 11, 2013

    @SvenDowideit
    Contributor

    @kscherer go on, blog your work! - I'm very curious too, if i get time.... :)

  6. timruffles commented on Jan 13, 2014

    @timruffles
    Contributor

    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.

  7. unclejack commented on May 14, 2014

    @unclejack
    Contributor

    @kscherer Have you tested the btrfs storage backend?

  8. kscherer commented on May 14, 2014

    @kscherer
    Author

    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.

  9. jessfraz commented on Feb 25, 2015

    @jessfraz
    Contributor

    can you see if this is a still an issue with the latest version of docker

  10. added
    area/storage
    kind/enhancement
    on Mar 2, 2015
  11. kscherer commented on Mar 3, 2015

    @kscherer
    Author

    Docker 1.5 on Ubuntu 14.04 with 3.16 utopic LTS kernel.

    The current stable poky release is dizzy:

    cd <buildarea>
    mkdir downloads
    chmod 777 downloads
    git clone --branch dizzy git://git.yoctoproject.org/poky
    source poky/oe-init-build-env mybuild
    ln -s ../downloads .
    bitbake -c fetchall core-image-minimal
    time bitbake core-image-minimal
    

    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.

  12. unclejack commented on Apr 6, 2015

    @unclejack
    Contributor

    @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.

  13. kscherer commented on Apr 7, 2015

    @kscherer
    Author

    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

  14. kscherer commented on Jul 10, 2015

    @kscherer
    Author

    Update for Docker 1.7

    • Ubuntu 14.04.2
    • Vivid kernel 3.19.0-21-generic
    • Dual 6C Xeon with 64GB RAM and 100GB root SSD and dual 3TB RAID0

    Building poky, fido release, core-image-minimal on a ext4 bind mount with the docker
    image using different storage backends.

    cd <buildarea>
    mkdir downloads
    git clone --branch fido git://git.yoctoproject.org/poky
    source poky/oe-init-build-env mybuild
    ln -s ../downloads .
    sed -i 's/#MACHINE ?= "qemux86-64"/MACHINE ?= "qemux86-64"/' conf/local.conf
    bitbake -c fetchall core-image-minimal
    time bitbake core-image-minimal
    

    Bare-metal:

    real    33m5.260s
    user    289m41.356s
    sys     27m23.488s
    

    Aufs:

    real    40m24.416s
    user    258m48.932s
    sys     56m29.284s
    

    Devicemapper with official binary in loopback mode:

    real    35m24.415s
    user    289m10.660s
    sys     34m21.168s
    

    Devicemapper with my own compiled dynamic binary:

    real    34m18.387s
    user    294m1.720s
    sys     31m43.764s
    

    Overlayfs:

    real    33m46.890s
    user    293m40.084s
    sys     35m31.480s
    

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/storageexp/expertkind/enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions