From be1d73b78fc5d13db44e444c127162ee9e011d16 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 04:41:40 +0000 Subject: [PATCH] Optimize VS Code extension installation by batching Replace sequential installation loop with a single batch command. This reduces overhead by invoking the `code` process only once for all missing extensions. Verified with benchmark showing significant reduction in execution time for multiple extensions. Co-authored-by: kidchenko <5432753+kidchenko@users.noreply.github.com> --- tools/install-vscode-extensions.sh | 32 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tools/install-vscode-extensions.sh b/tools/install-vscode-extensions.sh index ef27c6b..67e099b 100755 --- a/tools/install-vscode-extensions.sh +++ b/tools/install-vscode-extensions.sh @@ -81,7 +81,9 @@ installed=$(code --list-extensions | tr '[:upper:]' '[:lower:]') installed_count=0 skipped_count=0 failed_count=0 +to_install=() +set +e while IFS= read -r ext_id; do [[ -z "$ext_id" ]] && continue @@ -97,16 +99,28 @@ while IFS= read -r ext_id; do if [[ "$DRY_RUN" == true ]]; then echo " → Would install: $ext_id" else - echo -n " Installing $ext_id... " - if code --install-extension "$ext_id" --force &>/dev/null; then - echo "✓" - ((installed_count++)) - else - echo "✗" - ((failed_count++)) - fi + to_install+=("$ext_id") fi -done <<< "$extensions" +done < <(echo "$extensions") +set -e + +# Install missing extensions in batch +if [[ "${#to_install[@]}" -gt 0 ]]; then + echo -n " Installing ${#to_install[@]} extensions... " + + install_args=() + for ext in "${to_install[@]}"; do + install_args+=("--install-extension" "$ext") + done + + if code "${install_args[@]}" --force &>/dev/null; then + echo "✓" + ((installed_count+=${#to_install[@]})) + else + echo "✗" + ((failed_count+=${#to_install[@]})) + fi +fi echo "" if [[ "$DRY_RUN" == true ]]; then