Skip to content

perf: stop reinstalling psql, which the runner image already has - #61

Merged
alukach merged 1 commit into
mainfrom
perf/skip-redundant-psql-install
Sep 14, 2026
Merged

alukach merged 1 commit into
mainfrom
perf/skip-redundant-psql-install

Conversation

@alukach

@alukach alukach commented Sep 14, 2026

Copy link
Copy Markdown
Member

Both workflows ran this before touching the database:

sudo apt-get update
sudo apt-get install -y postgresql-client

The ubuntu-24.04 runner image (what ubuntu-latest resolves to) already ships PostgreSQL 16.15 — only the service is disabled by default, so psql is on PATH already. The step was installing something that was already there, at the cost of an apt-get update index refresh.

In the last reset run that was ~9 seconds (20:36:32.6620:36:41.46), which was most of that job's wall clock — the actual work takes about a second. In deploy.yml it's the same 9 seconds against a multi-minute job, so the saving there is real but minor.

The change

Install only when psql is genuinely missing:

if command -v psql > /dev/null; then
  psql --version
else
  echo "psql not on the runner image; installing"
  sudo apt-get update
  sudo apt-get install -y --no-install-recommends postgresql-client
fi

Deleting the step outright would be shorter, but it would make the job depend silently on a property of the runner image we don't control. The guard keeps that dependency soft for the price of one conditional, and is free in the normal case. The fallback also picks up --no-install-recommends.

Applied in reset-data.yml (its own step, renamed Ensure psql) and inline in deploy.yml's Load Workshop Data step.

Verification

Both branches of the guard exercised locally:

  • psql present → psql (PostgreSQL) 14.13, exit 0
  • psql off PATHpsql not on the runner image; installing, exit 0

Both workflows still parse as YAML and their shell steps pass bash -n.

Testing this before #60 merges

This branches from main, so it still carries the ref input that #60 removes. To dispatch the reset workflow from this branch, set ref to perf/skip-redundant-psql-install so the checkout matches the dispatched branch — otherwise it checks out main and fails on the missing scripts/fixture_collections.py, exactly as in the run that prompted #60.

Once #60 merges this branch can be rebased and that caveat disappears.

Honest sizing: this saves seconds, not minutes. Worth it because it is nearly free, not because the job was slow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P1CCcrx5fDKuAGsNh8DUFG

Both workflows ran `apt-get update && apt-get install -y postgresql-client`
before touching the database. The ubuntu-24.04 runner image already ships
PostgreSQL 16.15 -- only the service is disabled, so psql is on PATH
already -- and the install cost about 9 seconds of index refresh for
nothing. In the reset job that was most of the wall clock.

Install only when psql is genuinely missing, rather than deleting the step,
so this still works if a future image drops PostgreSQL. The fallback also
gains --no-install-recommends.

Verified both branches of the guard: with psql present it prints the
version and exits 0; with it off PATH it takes the install path. Both
workflows still parse and their shell is valid.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1CCcrx5fDKuAGsNh8DUFG
@alukach alukach changed the title Stop reinstalling psql, which the runner image already has perf: stop reinstalling psql, which the runner image already has Sep 14, 2026
@alukach
alukach merged commit 6dd1fde into main Sep 14, 2026
3 checks passed
@alukach
alukach deleted the perf/skip-redundant-psql-install branch September 14, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant