perf(web): reuse incremental build and status caches
This commit is contained in:
@@ -6,7 +6,7 @@ repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
source "${repo_root}/tools/web/native-build-env.sh"
|
||||
|
||||
build_target="${BLENDER_BUILD_TARGET:-blender}"
|
||||
jobs="${BLENDER_BUILD_JOBS:-2}"
|
||||
jobs="${BLENDER_BUILD_JOBS:-$(WEB_BUILD_MEMORY_GIB_PER_JOB=6 WEB_BUILD_JOBS_CAP=12 bash "${repo_root}/tools/web/compute-build-jobs.sh")}"
|
||||
cmake --build "${BLENDER_BUILD_DIR}" --target "${build_target}" --parallel "${jobs}"
|
||||
test -x "${BLENDER_BUILD_DIR}/bin/blender"
|
||||
|
||||
|
||||
@@ -8,9 +8,18 @@ configure_variant() {
|
||||
local name="$1"
|
||||
local threads="$2"
|
||||
local build_dir="${repo_root}/build_web-${name}"
|
||||
emcmake cmake --fresh -S "${repo_root}/web/engine" -B "${build_dir}" -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release -DWEB_ENGINE_THREADS="${threads}"
|
||||
cmake --build "${build_dir}" --target web_engine
|
||||
local configure_args=(
|
||||
-S "${repo_root}/web/engine"
|
||||
-B "${build_dir}"
|
||||
-G Ninja
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DWEB_ENGINE_THREADS="${threads}"
|
||||
)
|
||||
if [[ "${WEB_ENGINE_FORCE_RECONFIGURE:-0}" == "1" ]]; then
|
||||
configure_args=(--fresh "${configure_args[@]}")
|
||||
fi
|
||||
emcmake cmake "${configure_args[@]}"
|
||||
cmake --build "${build_dir}" --target web_engine --parallel "${WEB_BUILD_JOBS:-$(bash "${repo_root}/tools/web/compute-build-jobs.sh")}"
|
||||
test -s "${build_dir}/web_engine.js"
|
||||
test -s "${build_dir}/web_engine.wasm"
|
||||
printf '%s variant ok: %s\n' "${name}" "${build_dir}"
|
||||
|
||||
29
tools/web/compute-build-jobs.sh
Executable file
29
tools/web/compute-build-jobs.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Choose a high-throughput but memory-safe default. Callers can override with
|
||||
# WEB_BUILD_JOBS; the per-job memory estimate keeps large Blender/Emscripten
|
||||
# links from swapping while still using more than the historical -j8 default
|
||||
# on hosts with enough RAM.
|
||||
if [[ -n "${WEB_BUILD_JOBS:-}" ]]; then
|
||||
printf '%s\n' "${WEB_BUILD_JOBS}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cpu_count="$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '8')"
|
||||
memory_kib="$(awk '/MemAvailable:/ { print $2; exit }' /proc/meminfo 2>/dev/null || printf '0')"
|
||||
memory_per_job_gib="${WEB_BUILD_MEMORY_GIB_PER_JOB:-4}"
|
||||
job_cap="${WEB_BUILD_JOBS_CAP:-16}"
|
||||
|
||||
if [[ ! "${cpu_count}" =~ ^[0-9]+$ ]] || ((cpu_count < 1)); then cpu_count=8; fi
|
||||
if [[ ! "${memory_kib}" =~ ^[0-9]+$ ]] || ((memory_kib < 1)); then memory_kib=$((8 * 1024 * 1024)); fi
|
||||
if [[ ! "${memory_per_job_gib}" =~ ^[0-9]+$ ]] || ((memory_per_job_gib < 1)); then memory_per_job_gib=4; fi
|
||||
if [[ ! "${job_cap}" =~ ^[0-9]+$ ]] || ((job_cap < 1)); then job_cap=16; fi
|
||||
|
||||
memory_jobs=$((memory_kib / (memory_per_job_gib * 1024 * 1024)))
|
||||
if ((memory_jobs < 2)); then memory_jobs=2; fi
|
||||
jobs=$cpu_count
|
||||
if ((jobs > memory_jobs)); then jobs=$memory_jobs; fi
|
||||
if ((jobs > job_cap)); then jobs=$job_cap; fi
|
||||
if ((jobs < 2)); then jobs=2; fi
|
||||
printf '%s\n' "${jobs}"
|
||||
@@ -40,8 +40,10 @@ if [[ -d /dev/shm && -w /dev/shm ]]; then
|
||||
else
|
||||
export EM_CACHE="${EM_CACHE-${web_workspace_root}/.emcache}"
|
||||
fi
|
||||
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL-8}"
|
||||
export NINJAFLAGS="${NINJAFLAGS--j8}"
|
||||
web_build_jobs="$(WEB_BUILD_MEMORY_GIB_PER_JOB=4 WEB_BUILD_JOBS_CAP=16 bash "${web_workspace_root}/tools/web/compute-build-jobs.sh")"
|
||||
export WEB_BUILD_JOBS="${WEB_BUILD_JOBS-${web_build_jobs}}"
|
||||
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL-${WEB_BUILD_JOBS}}"
|
||||
export NINJAFLAGS="${NINJAFLAGS--j${WEB_BUILD_JOBS}}"
|
||||
export WEB_EMSCRIPTEN_CFLAGS="-sENVIRONMENT=web,worker -sMODULARIZE=1 -sEXPORT_ES6=1"
|
||||
export WEB_EMSCRIPTEN_LDFLAGS="-sALLOW_MEMORY_GROWTH=1 -sFILESYSTEM=1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user