httpd: Limit concurrent diffs

The limits on commit and diff responses bound each request, but not
how many run at once. Each request runs on its own blocking thread and
keeps running after its client disconnects, so a client sending many
requests for large diffs in parallel can still exhaust httpd's memory.

At most 4 commit, diff and diff stats requests now compute diffs at the
same time. Others wait for up to 10 seconds, which takes no memory
beyond the request, and then fail with 503 and `Retry-After`. Waiting
instead of failing at once keeps pages that request many commits at
once, such as repo listings in deployed explorers, working.
This commit is contained in:
Rūdolfs Ošiņš
2026-12-01 16:30:56 +01:00
parent 9dd13264e0
commit 3d353ca8ad
5 changed files with 63 additions and 0 deletions
+3
View File
@@ -46,6 +46,9 @@ Explorer supports httpd 0.28.0 and newer, set by `minimumSupportedVersion` in
files as binary.
- Changed in place: `git diff --numstat`, also behind `/diff/:base/:oid/stats`,
counts files over 1 MiB as binary, with no lines.
- Changed in place: the commit, diff and diff stats endpoints return 503 with
`Retry-After` when no diff slot frees up within 10 seconds. Older clients show
it as a failed request.
- Read by: client.
## 0.31.0