Skip to content

tests(state): robust margins and deterministic ordering for the wait/future tests - #631

Merged
transfix merged 1 commit into
masterfrom
fix/state-wait-test-margins
Oct 15, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/state-wait-test-margins

Conversation

@transfix

Copy link
Copy Markdown
Owner

StateTestFixture.WaitForValueWithTimeout failed on a loaded windows-2022
runner (#630, recipe / windows-2022 / Release):

cvc::timeout_error: Timeout waiting for state value to be initialized

after 345 ms. Its success half started a writer that sleeps 50 ms and allowed
the wait only 200 ms, and the runner took longer than that to schedule the
write. Several neighbouring tests had the same weakness or a worse one:

  • WaitForValueWithTimeout, WaitForDataWithTimeout and ValueFutureGetFor
    (50 ms writer, 200 ms wait) and FutureProducerConsumerPattern (1 s per
    item): waits that are expected to SUCCEED now use kSucceedWait (5 s). They
    return as soon as the write lands, so passing runs take as long as before.
    The halves that are expected to time out keep their short 50 ms waits on
    keys nothing writes.
  • ValueFutureGet: a state_future sees only writes made after it connects
    (it listens to valueChanged). The writer slept 100 ms and the future was
    created after the thread started, so on a slow runner the future could
    miss the write, and future.get() would then block forever. The future is
    now created first, and the writer waits on a go signal released after the
    not-ready check.
  • MultipleFuturesOnSameState: the same miss through a fixed 50 ms "give
    threads time" sleep. A boost::barrier now holds the write until all five
    futures are connected.

ValueFutureWaitFor needed nothing: the setter emits valueChanged
synchronously.

Verified on Windows (MSVC 2022, local cvcpkg prefix):

  • the nine wait/future tests pass 50/50 repeats;
  • under load, 12 concurrent processes x 20 repeats: 240/240;
  • the full state_test passes, 164 tests;
  • ValueFutureGet and MultipleFuturesOnSameState now finish in about 1 ms
    instead of 100 and 50 ms;
  • git clang-format against master reports nothing.

…stic ordering

StateTestFixture.WaitForValueWithTimeout failed on a loaded windows-2022
runner (#630, recipe / windows-2022 / Release):

    cvc::timeout_error: Timeout waiting for state value to be initialized

after 345 ms. Its success half started a writer that sleeps 50 ms and allowed
the wait only 200 ms, and the runner took longer than that to schedule the
write. Several neighbouring tests had the same weakness or a worse one:

- WaitForValueWithTimeout, WaitForDataWithTimeout and ValueFutureGetFor
  (50 ms writer, 200 ms wait) and FutureProducerConsumerPattern (1 s per
  item): waits that are expected to SUCCEED now use kSucceedWait (5 s). They
  return as soon as the write lands, so passing runs take as long as before.
  The halves that are expected to time out keep their short 50 ms waits on
  keys nothing writes.
- ValueFutureGet: a state_future sees only writes made after it connects
  (it listens to valueChanged). The writer slept 100 ms and the future was
  created after the thread started, so on a slow runner the future could
  miss the write, and future.get() would then block forever. The future is
  now created first, and the writer waits on a go signal released after the
  not-ready check.
- MultipleFuturesOnSameState: the same miss through a fixed 50 ms "give
  threads time" sleep. A boost::barrier now holds the write until all five
  futures are connected.

ValueFutureWaitFor needed nothing: the setter emits valueChanged
synchronously.

Verified on Windows (MSVC 2022, local cvcpkg prefix):
- the nine wait/future tests pass 50/50 repeats;
- under load, 12 concurrent processes x 20 repeats: 240/240;
- the full state_test passes, 164 tests;
- ValueFutureGet and MultipleFuturesOnSameState now finish in about 1 ms
  instead of 100 and 50 ms;
- git clang-format against master reports nothing.
@transfix
transfix merged commit d8efb44 into master Oct 15, 2026
15 checks passed
@transfix
transfix deleted the fix/state-wait-test-margins branch October 15, 2026 05:56
transfix added a commit that referenced this pull request Oct 17, 2026
Minor release. It carries:
- the world clock: lockstep and batch, followers, the sim.* binding, and nav
  on the clock (#629, #630, #631, #640);
- the units registry with SI <-> normalized-frame conversions (#632);
- cvc::physics with the Jolt backend (#641);
- the material trainer on the kinematic bicycle and its pycvc bindings
  (#642).
Bumps project(VERSION) 3.5.1 -> 3.6.0 and every cvcpkg recipe's
upstream_version to match. cvc_revision stays 1, per the recipe-version gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant