Skip to content

Add goals_perftest and write down what loads the database - #25

Merged
SupraSummus merged 2 commits into
mainfrom
claude/trusting-hopper-8t9t2f
Oct 8, 2026
Merged

SupraSummus merged 2 commits into
mainfrom
claude/trusting-hopper-8t9t2f

Conversation

@SupraSummus

Copy link
Copy Markdown
Member

Summary

The database is the hardest part to scale, so this measures how much work goals and workers give it.
No library code changes.

  • ./manage.py goals_perftest (in example_app, not shipped) builds a graph of goals, commits it, starts busy or threaded workers and reports throughput, worker CPU, what worker connections wait for, and database cost per goal: statements, transactions, WAL, buffer pages, rows, and server CPU when the server is local.
    Scenarios: independent goals, a chain, the butterfly network from Butterfly network #14 (closed in favour of this), and idle workers.
  • database-load.md has the numbers, how to estimate the load for a given database, and findings.
    TODO gets the most promising one to investigate and small fixes the measurements found.

Some numbers (PostgreSQL 16 on the same 4-core machine, no-op handlers):

per goal independent, busy worker threaded, 64 threads, 100 ms handlers
transactions 1.03 3.1
statements 9.1 13.4
WAL 0.9 kB 1.5 kB
server CPU 1.7 ms 3.1 - 3.7 ms

An idle busy worker runs 7 transactions per second.

Test plan

  • poetry run pytest (95 passed), poetry run mypy ., poetry run flake8
  • One smoke test runs the command on a small butterfly network and checks it deletes its goals
  • Command runs locally for every scenario, busy and threaded workers, with and without pg_stat_statements

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gr3xEoHp8cwWtEUknjcjsM


Generated by Claude Code

SupraSummus and others added 2 commits October 8, 2026 19:09
Builds a graph of goals - independent ones, a chain, or the butterfly
network from the perftest branch - commits it, starts busy or threaded
workers and reports:
- time, goals/s and ms per dependency level, and with --handler-time
  (handlers sleeping like waiting for a remote API) the share of the
  throughput of workers always busy,
- worker CPU and what worker connections wait for, sampled from
  pg_stat_activity,
- database cost per goal in units that depend little on hardware:
  statements, transactions, WAL, buffer pages and rows, plus CPU time
  of server processes when the server runs locally. Per-statement
  numbers come from pg_stat_statements, if installed.

The idle scenario reports the same per second of an idle worker.

It lives in example_app, so it isn't shipped with the package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gr3xEoHp8cwWtEUknjcjsM
database-load.md has the cost per goal and per idle worker, measured
with goals_perftest, how to estimate it for a given database, and
findings. The most promising one, picking getting expensive with dead
index entries at the head of the queue, goes to TODO to investigate,
next to small fixes the measurements found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gr3xEoHp8cwWtEUknjcjsM
@SupraSummus
SupraSummus merged commit 45e021a into main Oct 8, 2026
5 checks passed
@SupraSummus
SupraSummus deleted the claude/trusting-hopper-8t9t2f branch October 8, 2026 19:12
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