Decompose: Documented concurrency contract (throughput, per-request bounds, failure semantics) — Phase 2: Per-request bounds (questions 2, 3, 4) #70

Closed
opened 2026-06-22 16:31:51 +00:00 by Mark · 0 comments
Owner

Phase 2: Per-request bounds (questions 2, 3, 4)

Goal: Lock the per-request resource limits.

Specifically:

  1. Per-request timeout? Answer: 60 seconds for digitize, 30
    seconds for export. Justify: a 4 MP image at 0.4mm density is
    ~600K stitches, generated in < 5 seconds; 60s gives 12× headroom.
  2. Per-request memory cap? Answer: 1024 MB. Justify: the raster
    pipeline at 4 MP peaks at ~800 MB.
  3. Cancellation? Answer: yes — when the client disconnects, the
    worker thread is interrupted within 1 second (set a flag the
    pipeline checks between stages; full thread cancellation is unsafe
    because of numpy/scipy GIL interactions).

Files:

  • Modify: docs/concurrency.md (add these 3 answers)

Acceptance:

  • All 3 questions answered with value, rationale, source.
  • A test asserts that a request exceeding the timeout returns 504
    Gateway Timeout.
  • A test asserts that a request exceeding the memory cap returns
    503 with a clear error.
  • A test asserts that cancelling the client connection causes the
    worker to stop within 1 second.

Depends on: P1 (overall policy).



Decomposed from easystitch#43

## Phase 2: Per-request bounds (questions 2, 3, 4) **Goal:** Lock the per-request resource limits. **Specifically:** 2. **Per-request timeout?** Answer: 60 seconds for digitize, 30 seconds for export. Justify: a 4 MP image at 0.4mm density is ~600K stitches, generated in < 5 seconds; 60s gives 12× headroom. 3. **Per-request memory cap?** Answer: 1024 MB. Justify: the raster pipeline at 4 MP peaks at ~800 MB. 4. **Cancellation?** Answer: yes — when the client disconnects, the worker thread is interrupted within 1 second (set a flag the pipeline checks between stages; full thread cancellation is unsafe because of numpy/scipy GIL interactions). **Files:** - Modify: `docs/concurrency.md` (add these 3 answers) **Acceptance:** - All 3 questions answered with value, rationale, source. - A test asserts that a request exceeding the timeout returns 504 Gateway Timeout. - A test asserts that a request exceeding the memory cap returns 503 with a clear error. - A test asserts that cancelling the client connection causes the worker to stop within 1 second. **Depends on:** P1 (overall policy). --- --- _Decomposed from [easystitch#43](https://forgejo.tail018ac4.ts.net/Mark/easystitch/issues/43)_
Mark closed this issue 2026-06-23 16:36:10 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/easystitch#70
No description provided.