Skip to content

Commit ba0294e

Browse files
committed
Explicitly set jemalloc's page size to the values Debian uses for their builds
Also, this adds the explicit `--build` flag to `./configure` for the bundled jemalloc, since we technically do cross-builds for 32bit architectures and this helps `./configure` understand that (and do userspace detection instead of kernel detection) better.
1 parent b004e0f commit ba0294e

File tree

7 files changed

+112
-0
lines changed

7 files changed

+112
-0
lines changed

5.0/32bit/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ RUN set -eux; \
3838
ca-certificates \
3939
wget \
4040
\
41+
dpkg-dev \
4142
gcc \
4243
libc6-dev-i386 gcc-multilib \
4344
make \
@@ -60,6 +61,21 @@ RUN set -eux; \
6061
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
6162
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
6263
\
64+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
65+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
66+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
67+
extraJemallocConfigureFlags="--build=$gnuArch"; \
68+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
69+
dpkgArch="$(dpkg --print-architecture)"; \
70+
case "${dpkgArch##*-}" in \
71+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
72+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
73+
esac; \
74+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
75+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
76+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
77+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
78+
\
6379
make -C /usr/src/redis -j "$(nproc)" 32bit; \
6480
make -C /usr/src/redis install; \
6581
\

5.0/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ RUN set -eux; \
3838
ca-certificates \
3939
wget \
4040
\
41+
dpkg-dev \
4142
gcc \
4243
libc6-dev \
4344
make \
@@ -60,6 +61,21 @@ RUN set -eux; \
6061
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
6162
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
6263
\
64+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
65+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
66+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
67+
extraJemallocConfigureFlags="--build=$gnuArch"; \
68+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
69+
dpkgArch="$(dpkg --print-architecture)"; \
70+
case "${dpkgArch##*-}" in \
71+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
72+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
73+
esac; \
74+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
75+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
76+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
77+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
78+
\
6379
make -C /usr/src/redis -j "$(nproc)" all; \
6480
make -C /usr/src/redis install; \
6581
\

5.0/alpine/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN set -eux; \
1818
\
1919
apk add --no-cache --virtual .build-deps \
2020
coreutils \
21+
dpkg-dev dpkg \
2122
gcc \
2223
linux-headers \
2324
make \
@@ -46,6 +47,21 @@ RUN set -eux; \
4647
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
4748
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
4849
\
50+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
51+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
52+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
53+
extraJemallocConfigureFlags="--build=$gnuArch"; \
54+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
55+
dpkgArch="$(dpkg --print-architecture)"; \
56+
case "${dpkgArch##*-}" in \
57+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
58+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
59+
esac; \
60+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
61+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
62+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
63+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
64+
\
4965
make -C /usr/src/redis -j "$(nproc)" all; \
5066
make -C /usr/src/redis install; \
5167
\

6.0/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ RUN set -eux; \
3838
ca-certificates \
3939
wget \
4040
\
41+
dpkg-dev \
4142
gcc \
4243
libc6-dev \
4344
libssl-dev \
@@ -61,6 +62,21 @@ RUN set -eux; \
6162
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
6263
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
6364
\
65+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
66+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
67+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
68+
extraJemallocConfigureFlags="--build=$gnuArch"; \
69+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
70+
dpkgArch="$(dpkg --print-architecture)"; \
71+
case "${dpkgArch##*-}" in \
72+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
73+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
74+
esac; \
75+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
76+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
77+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
78+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
79+
\
6480
export BUILD_TLS=yes; \
6581
make -C /usr/src/redis -j "$(nproc)" all; \
6682
make -C /usr/src/redis install; \

6.0/alpine/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN set -eux; \
1818
\
1919
apk add --no-cache --virtual .build-deps \
2020
coreutils \
21+
dpkg-dev dpkg \
2122
gcc \
2223
linux-headers \
2324
make \
@@ -46,6 +47,21 @@ RUN set -eux; \
4647
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
4748
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
4849
\
50+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
51+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
52+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
53+
extraJemallocConfigureFlags="--build=$gnuArch"; \
54+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
55+
dpkgArch="$(dpkg --print-architecture)"; \
56+
case "${dpkgArch##*-}" in \
57+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
58+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
59+
esac; \
60+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
61+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
62+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
63+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
64+
\
4965
export BUILD_TLS=yes; \
5066
make -C /usr/src/redis -j "$(nproc)" all; \
5167
make -C /usr/src/redis install; \

Dockerfile-alpine.template

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN set -eux; \
1818
\
1919
apk add --no-cache --virtual .build-deps \
2020
coreutils \
21+
dpkg-dev dpkg \
2122
gcc \
2223
linux-headers \
2324
make \
@@ -48,6 +49,21 @@ RUN set -eux; \
4849
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
4950
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
5051
\
52+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
53+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
54+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
55+
extraJemallocConfigureFlags="--build=$gnuArch"; \
56+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
57+
dpkgArch="$(dpkg --print-architecture)"; \
58+
case "${dpkgArch##*-}" in \
59+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
60+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
61+
esac; \
62+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
63+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
64+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
65+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
66+
\
5167
export BUILD_TLS=yes; \
5268
make -C /usr/src/redis -j "$(nproc)" all; \
5369
make -C /usr/src/redis install; \

Dockerfile.template

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ RUN set -eux; \
3838
ca-certificates \
3939
wget \
4040
\
41+
dpkg-dev \
4142
gcc \
4243
libc6-dev \
4344
libssl-dev \
@@ -63,6 +64,21 @@ RUN set -eux; \
6364
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
6465
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
6566
\
67+
# https://github.com/jemalloc/jemalloc/issues/467 -- we need to patch the "./configure" for the bundled jemalloc to match how Debian compiles, for compatibility
68+
# (also, we do cross-builds, so we need to embed the appropriate "--build=xxx" values to that "./configure" invocation)
69+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
70+
extraJemallocConfigureFlags="--build=$gnuArch"; \
71+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
72+
dpkgArch="$(dpkg --print-architecture)"; \
73+
case "${dpkgArch##*-}" in \
74+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
75+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
76+
esac; \
77+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
78+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
79+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
80+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
81+
\
6682
export BUILD_TLS=yes; \
6783
make -C /usr/src/redis -j "$(nproc)" all; \
6884
make -C /usr/src/redis install; \

0 commit comments

Comments
 (0)