Skip to content

Commit

Permalink
ci: ensure jemalloc is configured _without_ MADV_FREE
Browse files Browse the repository at this point in the history
Previously, jemalloc would default to MADV_FREE which could lead
to surprising results; i.e., no reduction in RSS until memory pressure.
This change ensures that jemalloc is always compiled with MADV_FREE
disabled, thus using MADV_DONTNEED.
See the corresponding issue for further details.

Release note: None
Resolves: #83790
  • Loading branch information
srosenberg committed Jul 8, 2022
1 parent 3c9b171 commit 52a3a0a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,13 @@ $(JEMALLOC_DIR)/Makefile: $(C_DEPS_DIR)/jemalloc-rebuild $(JEMALLOC_SRC_DIR)/con
mkdir -p $(JEMALLOC_DIR)
@# NOTE: If you change the configure flags below, bump the version in
@# $(C_DEPS_DIR)/jemalloc-rebuild. See above for rationale.
cd $(JEMALLOC_DIR) && $(JEMALLOC_SRC_DIR)/configure $(xconfigure-flags) --enable-prof
@# NOTE: we disable MADV_FREE; see https://github.com/cockroachdb/cockroach/issues/83790
export je_cv_madv_free="no" && cd $(JEMALLOC_DIR) && $(JEMALLOC_SRC_DIR)/configure $(xconfigure-flags) --enable-prof
JEMALLOC_MADV_FREE_ENABLED=$$(grep -E "^je_cv_madv_free=no$$" $(JEMALLOC_DIR)/config.log | awk -F'=' '{print $$2}'); \
if [[ "$$JEMALLOC_MADV_FREE_ENABLED" != "no" ]]; then \
echo "NOTE: using MADV_FREE with jemalloc can lead to surprising results; see https://github.com/cockroachdb/cockroach/issues/83790"; \
exit 1; \
fi

$(KRB5_SRC_DIR)/src/configure.in: | bin/.submodules-initialized

Expand Down
10 changes: 8 additions & 2 deletions c-deps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ configure_make(
"//conditions:default": [],
}),
env = select({
"//build/toolchains:dev": {"AR": ""},
"//conditions:default": {},
"//build/toolchains:dev": {
"AR": "",
# NOTE: we disable MADV_FREE; see https://github.com/cockroachdb/cockroach/issues/83790
"je_cv_madv_free": "no",
},
"//conditions:default": {
"je_cv_madv_free": "no",
},
}),
lib_source = "@jemalloc//:all",
out_static_libs = select({
Expand Down
8 changes: 8 additions & 0 deletions c-deps/buildcdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ for CONFIG in $CONFIGS; do
bazel build --config ci --config cross$CONFIG --//build/toolchains:prebuild_cdeps_flag $(echo "$TARGETS" | python3 -c 'import sys; input = sys.stdin.read().strip(); print(" ".join("//c-deps:{}_foreign".format(w) for w in input.split(" ")))')
BAZEL_BIN=$(bazel info bazel-bin --config ci --config cross$CONFIG)
for TARGET in $TARGETS; do
# verify jemalloc was configured without madv_free
if [[ $TARGET == libjemalloc ]]; then
JEMALLOC_MADV_FREE_ENABLED=$((grep -E "^je_cv_madv_free=no$" $BAZEL_BIN/c-deps/${TARGET}_foreign_foreign_cc/Configure.log | awk -F"=" '{print $2}') || true)
if [[ "$JEMALLOC_MADV_FREE_ENABLED" != "no" ]]; then
echo "NOTE: using MADV_FREE with jemalloc can lead to surprising results; see https://github.com/cockroachdb/cockroach/issues/83790"
exit 1
fi
fi
bundle $CONFIG $BAZEL_BIN/c-deps/${TARGET}_foreign
done
done
Expand Down
2 changes: 1 addition & 1 deletion c-deps/jemalloc-rebuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Bump the version below when changing jemalloc configure flags. Search for "BUILD
ARTIFACT CACHING" in build/common.mk for rationale.

5
6

0 comments on commit 52a3a0a

Please sign in to comment.