Skip to content

Commit 61e7c99

Browse files
authored
unix: call ulimit -n to avoid overheads (#468)
See inline comment in `base.Dockerfile` for why this hack is necessary. When upgrading my machine recently, the `rlim_max` value increased to ~1B, making `apt-get` invocations take multiple minutes to complete. https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1332440 seems to describe this issue. The cross building images have a sufficiently new apt that doesn't seem impacted.
1 parent 8999425 commit 61e7c99

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

cpython-unix/base.Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@ RUN ( echo 'amd64'; \
3333
echo 'i386'; \
3434
) > /var/lib/dpkg/arch
3535

36-
RUN apt-get update
36+
# apt iterates all available file descriptors up to rlim_max and calls
37+
# fcntl(fd, F_SETFD, FD_CLOEXEC). This can result in millions of system calls
38+
# (we've seen 1B in the wild) and cause operations to take seconds to minutes.
39+
# Setting a fd limit mitigates.
40+
#
41+
# Attempts at enforcing the limit globally via /etc/security/limits.conf and
42+
# /root/.bashrc were not successful. Possibly because container image builds
43+
# don't perform a login or use a shell the way we expect.
44+
RUN ulimit -n 10000 && apt-get update

cpython-unix/build.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Compression packages are needed to extract archives.
1111
#
1212
# Various other build tools are needed for various building.
13-
RUN apt-get install \
13+
RUN ulimit -n 10000 && apt-get install \
1414
bzip2 \
1515
file \
1616
libc6-dev \

cpython-unix/gcc.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% include 'base.Dockerfile' %}
2-
RUN apt-get install \
2+
RUN ulimit -n 10000 && apt-get install \
33
autoconf \
44
automake \
55
bison \

cpython-unix/xcb.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{% include 'build.Dockerfile' %}
2-
RUN apt-get install \
2+
RUN ulimit -n 10000 && apt-get install \
33
python

0 commit comments

Comments
 (0)