From 7959060850b93eab796b3a7e8253f2d3cb6a0feb Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Thu, 4 Jul 2024 10:12:52 +0200 Subject: [PATCH] Monorepo: disable autoloading optimization by default (take 2) (#48980) This PR is the second attempt to speed up monorepo installation by removing autoloading optimization setting from the configuration and performing the optimization where it is appropriate (composer post-install hooks and when building releases). In the installation context, the composer post-install hook will execute a background task to dump the optimized autoloading, while the installation process completes other tasks. --- .github/workflows/build-live-branch.yml | 4 ++-- .github/workflows/pr-build-live-branch.yml | 4 ++-- plugins/woocommerce/bin/package-update.sh | 6 ++++-- .../changelog/dev-speedup-deps-installation | 4 ++++ plugins/woocommerce/composer.json | 1 - plugins/woocommerce/package.json | 11 +++++++++++ 6 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 plugins/woocommerce/changelog/dev-speedup-deps-installation diff --git a/.github/workflows/build-live-branch.yml b/.github/workflows/build-live-branch.yml index 12e4e62fd73..db1004e9530 100644 --- a/.github/workflows/build-live-branch.yml +++ b/.github/workflows/build-live-branch.yml @@ -56,12 +56,12 @@ jobs: bash bin/build-zip.sh mkdir "$GITHUB_WORKSPACE/zips" - cp "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip" + mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip" cd "$GITHUB_WORKSPACE/zips" unzip -qq woocommerce.zip rm woocommerce.zip mv woocommerce woocommerce-dev - zip -q -r "woocommerce-dev.zip" "woocommerce-dev/" + zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/" rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev" # Plugin data is passed as a JSON object. diff --git a/.github/workflows/pr-build-live-branch.yml b/.github/workflows/pr-build-live-branch.yml index 63ad16bf20f..d43fc964500 100644 --- a/.github/workflows/pr-build-live-branch.yml +++ b/.github/workflows/pr-build-live-branch.yml @@ -66,13 +66,13 @@ jobs: mkdir "$GITHUB_WORKSPACE/zips" mkdir -p "$GITHUB_WORKSPACE/unzips/woocommerce" - cp "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip" + mv "$GITHUB_WORKSPACE/plugins/woocommerce/woocommerce.zip" "$GITHUB_WORKSPACE/zips/woocommerce.zip" cd "$GITHUB_WORKSPACE/zips" unzip -qq woocommerce.zip cp -r woocommerce "$GITHUB_WORKSPACE/unzips/woocommerce/woocommerce" rm woocommerce.zip mv woocommerce woocommerce-dev - zip -q -r "woocommerce-dev.zip" "woocommerce-dev/" + zip -q -r -9 "woocommerce-dev.zip" "woocommerce-dev/" rm -fR "$GITHUB_WORKSPACE/zips/woocommerce-dev" # Plugin data is passed as a JSON object. PLUGIN_DATA="{}" diff --git a/plugins/woocommerce/bin/package-update.sh b/plugins/woocommerce/bin/package-update.sh index 8f09ea6f7b0..874aec7886b 100755 --- a/plugins/woocommerce/bin/package-update.sh +++ b/plugins/woocommerce/bin/package-update.sh @@ -20,9 +20,11 @@ if [ ! -d "packages/" ]; then output 1 "run \"composer install\" before proceed." fi -# Autoloader +# Autoloader optimization is forced to prevent OOM fatal errors in JetPack Autoloader. +# We running the optimization in background to speedup build process, with dev-environments in mind. +# Building zips enforcing the optimization during the install process, so we are good around building releases as well. output 3 "Updating autoloader classmaps..." -composer dump-autoload +composer dump-autoload --optimize --quiet & output 2 "Done" if [ -z "$SKIP_UPDATE_TEXTDOMAINS" ]; then diff --git a/plugins/woocommerce/changelog/dev-speedup-deps-installation b/plugins/woocommerce/changelog/dev-speedup-deps-installation new file mode 100644 index 00000000000..96792c61bad --- /dev/null +++ b/plugins/woocommerce/changelog/dev-speedup-deps-installation @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Build: speedup dependencies installation by disabling composer optimize autoloading by default. diff --git a/plugins/woocommerce/composer.json b/plugins/woocommerce/composer.json index 35839fd93c5..80809c5668c 100644 --- a/plugins/woocommerce/composer.json +++ b/plugins/woocommerce/composer.json @@ -40,7 +40,6 @@ "yoast/phpunit-polyfills": "^2.0" }, "config": { - "optimize-autoloader": true, "preferred-install": { "woocommerce/action-scheduler": "dist" }, diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json index 2add42525f0..2d325435e60 100644 --- a/plugins/woocommerce/package.json +++ b/plugins/woocommerce/package.json @@ -107,6 +107,7 @@ "command": "test:php:env", "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -129,6 +130,7 @@ "command": "test:php:env", "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -154,6 +156,7 @@ "command": "test:php:env", "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -179,6 +182,7 @@ "command": "test:php:env", "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -205,6 +209,7 @@ "optional": true, "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -238,6 +243,7 @@ ], "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -384,6 +390,7 @@ ], "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -466,6 +473,7 @@ "optional": false, "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -494,6 +502,7 @@ "optional": false, "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -524,6 +533,7 @@ "optional": true, "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php", @@ -545,6 +555,7 @@ "optional": true, "changes": [ "client/admin/config/*.json", + "composer.json", "composer.lock", "includes/**/*.php", "patterns/**/*.php",