Skip to content

kanban: test_kanban_stress.cpp's own waitUntil uses hand-picked 20s/90s budgets, not MORPH_LADDER_DEADLINE_MS-scaled #264

Description

@Yaraslaut

What

examples/kanban/tests/test_kanban_stress.cpp's own waitUntil(pred, budget, step) helper (lines 139-150) polls with hand-picked fixed wall-clock budgets
that are not scaled by MORPH_LADDER_DEADLINE_MS, unlike every
pumpUntil-based wait in the ladder testkit:

template <typename Pred>
[[nodiscard]] bool waitUntil(Pred pred, std::chrono::milliseconds budget = std::chrono::milliseconds{20000},
                              std::chrono::milliseconds step = std::chrono::milliseconds{5}) {
    const auto deadline = std::chrono::steady_clock::now() + budget;
    while (!pred()) {
        if (std::chrono::steady_clock::now() >= deadline) {
            return false;
        }
        std::this_thread::sleep_for(step);
    }
    return true;
}

Call sites use the 20000ms default six times, plus one explicit 90000ms
budget (line 395) for a 32-way concurrent-drag/ThreadSanitizer stress case
over a real ThreadPoolExecutor{4}.

This is the same shape #223 flagged in test_ledger_reports.cpp
(pollUntilSettled, now fixed): a real, deliberate wall-clock poll against a
genuine thread pool (justified — this file's own header comment explains why
DeterministicExecutor isn't wireable here and a real pool is needed for the
ThreadSanitizer coverage), but with a fixed, hand-picked budget instead of one
scaled by MORPH_LADDER_DEADLINE_MS the way examples/common/testkit/ pump.hpp's pumpUntil/deadlineScale() scales every other ladder wait.

Found while triaging #223; not covered by that issue's grep (for (int i = 0; i < 100) since this helper uses a deadline-based loop, not a fixed iteration
count, and #223 never mentions this file.

Why it matters

Under a slow/loaded CI runner or a sanitizer build (exactly the case
MORPH_LADDER_DEADLINE_MS exists to compensate for — see pump.hpp's own
doc comment: "scales every pumpUntil default deadline uniformly (slow CI
runners, sanitizer builds)"), this file's fixed 20s/90s budgets don't grow
with the rest of the suite's polls, while every pumpUntil-based wait in the
same CI run does. This file is explicitly a ThreadSanitizer target
(file header: "run under ThreadSanitizer in CI"), which is exactly the
condition MORPH_LADDER_DEADLINE_MS scaling was introduced to cover.

Proposed fix

Once #223's corrected scope lands (a non-Qt waitUntil(pred, deadline)
helper sharing pump.hpp's MORPH_LADDER_DEADLINE_MS scale factor), point
this file's local waitUntil at it instead of hand-rolling its own
un-scaled version — one instance of invariant 6 (a guarantee reimplemented
per call site belongs in one place) rather than two now separately
un-scaled implementations.

This issue should stay blocked/deferred until #223 lands, since it's the
same helper this local one should delegate to.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ladderSubsystem: laddertriage: parkedDeferred with an explicit re-entry condition

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions