-
Notifications
You must be signed in to change notification settings - Fork 0
β‘ Bolt: Batch APT package installations in bootstrap.sh #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
swarm-protocol
merged 4 commits into
main
from
bolt-batch-apt-install-6206753697854150493
Feb 8, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
047766d
β‘ Bolt: Batch APT package installations in bootstrap.sh
google-labs-jules[bot] c7a30ae
β‘ Bolt: Batch APT package installations in bootstrap.sh (95% faster)
google-labs-jules[bot] 7bbc1e1
β‘ Bolt: Batch APT package installations & Performance Suite
google-labs-jules[bot] b112112
β‘ Bolt: Addressed feedback & finalized performance suite
google-labs-jules[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2026-02-08 - Preserving Abstractions in Performance Optimizations | ||
| **Learning:** When optimizing for performance (e.g., batching operations), it is critical to preserve existing code abstractions. Bypassing a function that handles specific logic (even if it's currently simple) can lead to regressions and maintenance issues if that function is later updated with necessary prerequisites (like repository registration or GPG key setup). | ||
| **Action:** Instead of bypassing functions to achieve batching, refactor them into "preparation" and "execution" phases. This allows batching the execution phase while still running the necessary preparation for each component. Measured 95.7% performance improvement in `apt` overhead by batching (42.7s -> 1.8s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Performance and Connectivity Testing Scripts | ||
|
|
||
| This directory contains scripts for measuring the performance of repository workflows and the connectivity of the development environment. | ||
|
|
||
| ## Available Scripts | ||
|
|
||
| ### 1. `benchmark_apt.sh` | ||
|
|
||
| This script benchmarks the performance of APT package installations. It compares the sequential installation strategy (installing environments one by one) against the batched strategy (installing all unique packages in a single call). | ||
|
|
||
| **Usage:** | ||
| ```bash | ||
| bash src/scripts/performance/benchmark_apt.sh | ||
| ``` | ||
|
|
||
| **What it measures:** | ||
| - Total execution time for sequential dry-runs. | ||
| - Total execution time for a single batched dry-run. | ||
| - Percentage improvement and time saved. | ||
|
|
||
| ### 2. `check_connectivity.sh` | ||
|
|
||
| This script measures the network latency to critical infrastructure endpoints used by the repository's bootstrap and development processes. | ||
|
|
||
| **Usage:** | ||
| ```bash | ||
| bash src/scripts/performance/check_connectivity.sh | ||
| ``` | ||
|
|
||
| **What it measures:** | ||
| - ICMP (ping) round-trip time (if available). | ||
| - HTTPS total response time using `curl`. | ||
| - Connectivity status for GitHub, Nix, and Debian repositories. | ||
|
|
||
| ## Purpose | ||
|
|
||
| These tools help developers: | ||
| - Verify the performance benefits of batching optimizations. | ||
| - Diagnose slow environment setup times. | ||
| - Identify network issues that may affect the development experience. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Performance benchmark for APT installation strategies | ||
| # Compares sequential vs batched installation using dry-runs. | ||
|
|
||
| REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) | ||
| cd "$REPO_ROOT" | ||
|
|
||
| envs=("common" "test" "docker" "documentation" "code-review" "refactoring" "wrangler" "terraform" "ansible" "security") | ||
|
|
||
| echo "β‘ Bolt Performance Benchmark: APT Installation" | ||
| echo "==============================================" | ||
|
|
||
| # Check if apt-get is available | ||
| if ! command -v apt-get &> /dev/null; then | ||
| echo "β Error: apt-get not found. This script requires a Debian-based system." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "--- 1. Sequential Simulation (Dry-run) ---" | ||
| start_seq=$(date +%s%3N) | ||
| for env in "${envs[@]}"; do | ||
| pkg_file="apt/$env/packages.txt" | ||
| if [ -f "$pkg_file" ]; then | ||
| pkgs=$(sed 's/#.*//' "$pkg_file" | xargs) | ||
| if [ -n "$pkgs" ]; then | ||
| printf "Processing %-15s ... " "$env" | ||
| if DEBIAN_FRONTEND=noninteractive apt-get install -s -y --no-install-recommends -o Debug::NoLocking=1 $pkgs > /dev/null 2>&1; then | ||
| echo "OK" | ||
| else | ||
| echo "FAILED" | ||
| fi | ||
| fi | ||
| fi | ||
| done | ||
| end_seq=$(date +%s%3N) | ||
| seq_time=$((end_seq - start_seq)) | ||
| echo "Sequential Total Time: ${seq_time}ms" | ||
| echo | ||
|
|
||
| echo "--- 2. Batched Simulation (Dry-run) ---" | ||
| start_batch=$(date +%s%3N) | ||
| all_packages="" | ||
| printf "Collecting packages ... " | ||
| for env in "${envs[@]}"; do | ||
| pkg_file="apt/$env/packages.txt" | ||
| if [ -f "$pkg_file" ]; then | ||
| all_packages+="$(sed 's/#.*//' "$pkg_file") " | ||
| fi | ||
| done | ||
| unique_packages=$(echo "$all_packages" | tr ' ' '\n' | grep -v '^$' | sort -u | xargs) | ||
| echo "Done ($(echo "$unique_packages" | wc -w) unique packages)" | ||
|
|
||
| printf "Executing batch install ... " | ||
| if [ -n "$unique_packages" ]; then | ||
| if DEBIAN_FRONTEND=noninteractive apt-get install -s -y --no-install-recommends -o Debug::NoLocking=1 $unique_packages > /dev/null 2>&1; then | ||
| echo "OK" | ||
| else | ||
| echo "FAILED" | ||
| fi | ||
| fi | ||
| end_batch=$(date +%s%3N) | ||
| batch_time=$((end_batch - start_batch)) | ||
| echo "Batched Total Time: ${batch_time}ms" | ||
| echo | ||
|
|
||
| echo "--- Summary ---" | ||
| if command -v awk &> /dev/null; then | ||
| improvement=$(awk "BEGIN {print ($seq_time - $batch_time) / $seq_time * 100}") | ||
| printf "β‘ Performance Improvement: %.2f%%\n" "$improvement" | ||
| printf "β±οΈ Time Saved: %dms\n" "$((seq_time - batch_time))" | ||
| else | ||
| echo "Sequential: ${seq_time}ms" | ||
| echo "Batched: ${batch_time}ms" | ||
| fi | ||
| echo "==============================================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Connectivity and Latency Test | ||
| # Measures response times to critical infrastructure endpoints. | ||
|
|
||
| echo "π Bolt Connectivity Check: Latency Measurement" | ||
| echo "===============================================" | ||
|
|
||
| endpoints=( | ||
| "github.com" | ||
| "deb.debian.org" | ||
| "nixos.org" | ||
| "google.com" | ||
| ) | ||
|
|
||
| # Check if ping is available | ||
| HAS_PING=false | ||
| if command -v ping &> /dev/null; then | ||
| HAS_PING=true | ||
| fi | ||
|
|
||
| # Check if curl is available | ||
| HAS_CURL=false | ||
| if command -v curl &> /dev/null; then | ||
| HAS_CURL=true | ||
| fi | ||
|
|
||
| if [ "$HAS_PING" = false ] && [ "$HAS_CURL" = false ]; then | ||
| echo "β Error: This script requires 'ping' or 'curl' to measure latency." | ||
| exit 1 | ||
| fi | ||
|
|
||
| for host in "${endpoints[@]}"; do | ||
| printf "Testing %-20s ... " "$host" | ||
|
|
||
| if [ "$HAS_PING" = true ]; then | ||
| # Try pinging (3 packets) | ||
| latency=$(ping -c 3 "$host" 2>/dev/null | tail -1 | awk -F '/' '{print $5}') | ||
| if [ -n "$latency" ]; then | ||
| printf "Ping: %sms " "$latency" | ||
| else | ||
| printf "Ping: FAILED " | ||
| fi | ||
| fi | ||
|
|
||
| if [ "$HAS_CURL" = true ]; then | ||
| # Measure HTTP response time using curl | ||
| # time_total: The total time, in seconds, that the full operation lasted. | ||
| curl_latency=$(curl -o /dev/null -s -w "%{time_total}\n" "https://$host") | ||
| if [ $? -eq 0 ]; then | ||
| # Convert to ms | ||
| ms_latency=$(awk "BEGIN {print $curl_latency * 1000}") | ||
| printf "HTTPS: %.1fms" "$ms_latency" | ||
| else | ||
| printf "HTTPS: FAILED" | ||
| fi | ||
| fi | ||
| echo | ||
| done | ||
|
|
||
| echo "===============================================" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.