perf(forge): pr list and test requests ask git.magicbean.dev for less: PRs listed as issues, authors' permissions kept an hour #877
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: needs approval
beanstalk: running
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!877
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/forge-cheaper-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: perf · Risk: low · Tested on: Linux (CachyOS), against git.magicbean.dev · Needs: none
Why
git.magicbean.dev has been slow (pages at 3-4 s), and part of its load is our own tools asking it for more than they need.
forge.py pr listwalked every page of the pull request list, and each PR on it makes Forgejo load that PR's branches and repositories;--minethen threw most of it away.test_requests.pyfetched each PR through the same expensive endpoint, and asked for its author's permission again for every PR on every run (about 210 times in 3 hours, always the same author).What changed
The two scripts ask Forgejo for the same information through its cheaper issues endpoint, and the test requests keep an author's permission for an hour.
scripts/forge.py,pr list: reads/issues?type=pulls(it has the number, state, author, title andpull_request.mergedthat the list prints).--mineasks forcreated_by=<you>instead of fetching every page to filter.scripts/test_requests.py:pr_info()reads/issues/N(state, labels, author,pull_request.mergedanddraft), and refuses a number that isn't a PR.author_permission()keeps each author's permission forPERMISSION_TTL(an hour) inforge_permissions.jsonin the sign-in's folder; where that can't be written (a sandbox), it's kept for the run only.Measurements
Verdict: one page of the PR list takes 0.6 s instead of 8.9 s, and
pr list --minetakes 0.6 s in all.Hardware: git.magicbean.dev (Forgejo 17); client on Linux
Method: the same page fetched through each endpoint, back to back, signed in; then the changed commands run
How to reproduce:
python -I scripts/forge.py pr list --mine --state open7bacf846c00be61d/pulls)/issues?type=pulls), the same 50 PRs in the same orderpr list --mine --state openFlags and settings
None
Testing
Tested: On Linux against git.magicbean.dev:
pr list --mine --state open(my 5 open PRs, as before),pr list --state closed(merged ones show as merged), andtest_requests.py list(states and approvals shown;forge_permissions.jsonwritten).py_compileof both files. I didn't runtests/run_all.py(this PC runs no test suites, and the CI runner for the Python checks is off for now).tests/test_test_requests.pystands in forpr_infoas a whole, so it isn't affected.Not tested: Windows (the cache file is written with
write_private, as the sign-in is).Must be tested:
Risks
What could break: a maintainer giving an author write access shows in test requests within the hour, not at once (the
testing wantedlabel still works at once).Turning it off: revert the commit.
Compatibility: a new file,
forge_permissions.json, in the sign-in's folder; nothing else changes.Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). (not run: no test suites on this PC, and no runner for the Python checks right now)third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
WIP: perf(forge): pr list and test requests ask git.magicbean.dev for less: PRs listed as issues, authors' permissions kept an hourto perf(forge): pr list and test requests ask git.magicbean.dev for less: PRs listed as issues, authors' permissions kept an hour