Skip to content
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

Upload build output using parallel threads #4842

Closed
wants to merge 1 commit into from

Conversation

louis-md
Copy link
Collaborator

What it solves

Identical to safe-global/safe-docs#680 and safe-global/safe-homepage#541, this fix aims to drastically reduce deployment times to AWS.

How this PR fixes it

The issue is solved by uploading files in parallel using the & operator.

## What it solves

Identical to safe-global/safe-docs#680 and safe-global/safe-homepage#541, this fix aims to drastically reduce deployment times to AWS.

## How this PR fixes it

The issue is solved by uploading files in parallel using the `&` operator.
@katspaugh
Copy link
Member

katspaugh commented Jan 28, 2025

Pretty sure it's not good to launch so many processes in parallel. There are hundreds dozens of HTML files.

Comment on lines 15 to +20
for file in $(find . -name '*.html' | sed 's|^\./||'); do
aws s3 cp ${file%} $BUCKET/${file%.*} --content-type 'text/html'
aws s3 cp ${file%} $BUCKET/${file%.*} --content-type 'text/html' &
done

wait

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChatGPT suggested we can run them in batches like so:

# Max number of parallel processes
MAX_PARALLEL=20

# Counter to track the number of running processes
counter=0

for file in $(find . -name '*.html' | sed 's|^\./||'); do
    # Launch the process
    aws s3 cp "${file%}" "$BUCKET/${file%.*}" --content-type 'text/html' &

    # Increment the counter
    ((counter++))

    # If the counter reaches the max limit, wait for all processes to complete
    if ((counter >= MAX_PARALLEL)); then
        wait
        counter=0
    fi
done

# Wait for any remaining processes to complete
wait

@louis-md louis-md closed this Jan 28, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2025
@louis-md
Copy link
Collaborator Author

Closed in favor of #4843

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants