Repository navigation
✨ Add DD resource limits and cancellation - #2848
burgholzer wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
78ad6aa to
0ff773e
Compare
🤖 *AI text below* 🤖 Add optional shared storage budgets, deadlines, and stop tokens to DD packages. Preserve default call sites and the slab overflow guards. Use a DD-specific standard allocator and scoped allocator propagation to retain the macOS 13.3 deployment target without requiring PMR symbols. Keep stop sources mutable as required by libc++ and MSVC. Document cooperative checkpoints, counted storage, ownership, and package disposal after interruption. Test shared budgets, nested storage, aligned entries, cleanup, and cancellation without changing numerical settings. Assisted-by: GPT-6 via Codex
Remove deadlines and clock reads from DD resource checkpoints. Keep the optional shared byte budget and stop-token cancellation; callers that omit resource control retain their existing behavior. Document one optional C++20 timer per computation with stop-aware shutdown. Test expiration and early completion, preserving all cancellation and accounting contracts. The regression detects cancellation on normal timer shutdown. LLVM 23 inspection confirms no clock read or allocation on the successful checkpoint path. Assisted-by: GPT-6 via Codex
0ff773e to
2e989aa
Compare
|
🤖 AI text below 🤖 Closing as superseded by a simpler verifier design. Exception-based interruption of DD arithmetic and allocation conflicts with the exception-free direction of #2545. Strict recoverable allocation limits and recursive cancellation are not prerequisites for the initial verifier. The verifier will be developed on upstream main while #2545 remains in progress. Optional timeouts will use a caller-owned timer and normal result-returning cancellation checks between DD operations and within verifier-owned loops. Cancellation and timeout yield an explicit inconclusive outcome. One expensive DD operation may delay cancellation and worker joining; no strict timeout or memory guarantee is promised. We will defer the allocator and recursive-checkpoint plumbing, retain the existing tests and performance evidence as reference, and follow #2545's error-returning direction without depending on its unfinished implementation. |
🤖 AI text below 🤖
Description
Allow C++ DD callers to share an optional storage budget and cancellation token across separate packages.
dd::ResourceControlaccounts for DD storage and reports cancellation or a byte-budget failure throughResourceLimitExceeded. Existing package construction remains supported, with no cancellation polling or timer thread when controls are omitted.This is the standalone DD prerequisite for native equivalence checking, rebased onto
67bd68b3a5. It preserves #2841's slab overflow guards and contains no verifier, MLIR runtime, orchestration, or Python binding changes.Timeouts belong to the caller: one optional C++20
std::jthreadwaits until the deadline and requests cancellation. DD checkpoints never read the clock. The documented example uses a stop-aware wait so early completion does not wait for the deadline. The caller owns the extra thread budget and distinguishes timeout from user cancellation when needed. Both are cooperative and have no hard termination bound.The control must outlive its users, and callers must destroy an affected package after interruption. Accounted storage includes slabs, tables, roots, and trace scratch; it excludes dense exports, sampling, serialization, statistics scratch, allocator overhead, and stack storage. Reserved bytes are neither cumulative allocation volume nor process RSS.
A DD-specific standard allocator and
std::scoped_allocator_adaptorpreserve nested accounting and the macOS 13.3 deployment target without introducing PMR runtime requirements. Stop sources remain mutable for libc++ and MSVC.Performance and review:
Validation on the final code:
-O3/LTO flags, CPU 19, no concurrent builds) measured median wall times: baseline 175.13 / 117.07 ms, controls disabled 174.14 / 117.02 ms, caller timer 175.24 / 118.70 ms, and the old direct deadline 304.27 / 228.34 ms for Grover / QFT. Default-path differences are within noise; paired caller-timer overhead was 0.1% / 1.1%. Construction and destruction are included, and process CPU includes timer work. Memory accounting was unchanged.Implemented and reviewed with GPT-6 via Codex assistance. Actual macOS/MSVC execution was unavailable locally; hosted CI and human review remain pending.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).