From 17ab91401acf5734f07a51e8814347d65418bdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Heres?= Date: Thu, 13 Aug 2026 19:12:02 +0200 Subject: [PATCH] build: don't build the doc-generator binaries by default `datafusion/core/src/bin/` holds three binaries that regenerate the docs under `docs/source/user-guide`: `print_config_docs`, `print_runtime_config_docs` and `print_functions_docs`. They are auto-discovered by cargo with no `required-features`, so every `cargo build` links all three -- each ~174MB, against a crate whose own rlib they link in full. They are only ever run by `dev/update_config_docs.sh` and `dev/update_function_docs.sh` (and by the CI job that checks the committed docs are up to date), so they now sit behind a non-default `docs_generation` feature, and those scripts pass `--features docs_generation`. Effect on the two builds that matter: - Cold `cargo build -p datafusion`: the three binaries link *after* everything else has finished, so they sit on the critical path with nothing to overlap with. `cargo build --timings` shows them occupying the last 3.5s of the build (~8.8s of CPU). - Edit-a-file-in-core and rebuild, the tightest inner loop -- they are relinked every time: before: 3.0s 2.4s after: 1.3s 1.1s Verified that a default `cargo build -p datafusion` no longer produces them, that `--features docs_generation` does, and that `./dev/update_config_docs.sh` still regenerates `docs/source/user-guide/configs.md` byte-identically. Co-Authored-By: Claude Opus 5 --- datafusion/core/Cargo.toml | 22 ++++++++++++++++++++++ dev/update_config_docs.sh | 4 ++-- dev/update_function_docs.sh | 6 +++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml index 0fe48ddf6a3e0..81e0418dd2b26 100644 --- a/datafusion/core/Cargo.toml +++ b/datafusion/core/Cargo.toml @@ -39,6 +39,13 @@ all-features = true workspace = true [features] +# Enables the `print_config_docs`, `print_runtime_config_docs` and +# `print_functions_docs` binaries, which regenerate the docs under +# `docs/source/user-guide`. Off by default: they are only run by +# `dev/update_config_docs.sh` and `dev/update_function_docs.sh`, and each one +# links a ~174MB binary that would otherwise be relinked on every build of this +# crate. +docs_generation = [] nested_expressions = ["datafusion-functions-nested"] # This feature is deprecated. Use the `nested_expressions` feature instead. array_expressions = ["nested_expressions"] @@ -190,6 +197,21 @@ ignored = ["datafusion-doc", "datafusion-macros", "dashmap"] [target.'cfg(not(target_os = "windows"))'.dev-dependencies] nix = { version = "0.31.3", features = ["fs"] } +[[bin]] +name = "print_config_docs" +path = "src/bin/print_config_docs.rs" +required-features = ["docs_generation"] + +[[bin]] +name = "print_runtime_config_docs" +path = "src/bin/print_runtime_config_docs.rs" +required-features = ["docs_generation"] + +[[bin]] +name = "print_functions_docs" +path = "src/bin/print_functions_docs.rs" +required-features = ["docs_generation"] + [[bench]] harness = false name = "aggregate_query_sql" diff --git a/dev/update_config_docs.sh b/dev/update_config_docs.sh index 7ab998f3dad48..df40c65210bb9 100755 --- a/dev/update_config_docs.sh +++ b/dev/update_config_docs.sh @@ -27,8 +27,8 @@ cd "${ROOT_DIR}" source "${ROOT_DIR}/ci/scripts/utils/tool_versions.sh" TARGET_FILE="docs/source/user-guide/configs.md" -PRINT_CONFIG_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --bin print_config_docs" -PRINT_RUNTIME_CONFIG_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --bin print_runtime_config_docs" +PRINT_CONFIG_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --features docs_generation --bin print_config_docs" +PRINT_RUNTIME_CONFIG_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --features docs_generation --bin print_runtime_config_docs" echo "Inserting header" cat <<'EOF' > "$TARGET_FILE" diff --git a/dev/update_function_docs.sh b/dev/update_function_docs.sh index 86a272ae196c8..04266b8cbc0d3 100755 --- a/dev/update_function_docs.sh +++ b/dev/update_function_docs.sh @@ -27,7 +27,7 @@ cd "${ROOT_DIR}" source "${ROOT_DIR}/ci/scripts/utils/tool_versions.sh" TARGET_FILE="docs/source/user-guide/sql/aggregate_functions.md" -PRINT_AGGREGATE_FUNCTION_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --bin print_functions_docs -- aggregate" +PRINT_AGGREGATE_FUNCTION_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --features docs_generation --bin print_functions_docs -- aggregate" echo "Inserting header" cat <<'EOF' > "$TARGET_FILE" @@ -121,7 +121,7 @@ npx "prettier@${PRETTIER_VERSION}" --write "$TARGET_FILE" echo "'$TARGET_FILE' successfully updated!" TARGET_FILE="docs/source/user-guide/sql/scalar_functions.md" -PRINT_SCALAR_FUNCTION_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --bin print_functions_docs -- scalar" +PRINT_SCALAR_FUNCTION_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --features docs_generation --bin print_functions_docs -- scalar" echo "Inserting header" cat <<'EOF' > "$TARGET_FILE" @@ -165,7 +165,7 @@ npx "prettier@${PRETTIER_VERSION}" --write "$TARGET_FILE" echo "'$TARGET_FILE' successfully updated!" TARGET_FILE="docs/source/user-guide/sql/window_functions.md" -PRINT_WINDOW_FUNCTION_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --bin print_functions_docs -- window" +PRINT_WINDOW_FUNCTION_DOCS_COMMAND="cargo run --manifest-path datafusion/core/Cargo.toml --features docs_generation --bin print_functions_docs -- window" echo "Inserting header" cat <<'EOF' > "$TARGET_FILE"