Skip to content

Fixing future::wait_until (and wait_for) to return once future was made ready#7367

Open
hkaiser wants to merge 2 commits into
masterfrom
future_wait_until
Open

Fixing future::wait_until (and wait_for) to return once future was made ready#7367
hkaiser wants to merge 2 commits into
masterfrom
future_wait_until

Conversation

@hkaiser

@hkaiser hkaiser commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Future waits now stop promptly once the associated shared state transitions to ready.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a2187867-b499-4d4d-8a12-b49491109ea1

📥 Commits

Reviewing files that changed from the base of the PR and between de2cf58 and d478f99.

📒 Files selected for processing (8)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
🚧 Files skipped from review as they are similar to previous changes (7)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Timed sleeps can now be interrupted by a supplied predicate, returning whether the call was signaled or timed out.
    • Condition variables now support predicate-aware wait_until, improving early wake behavior with notifications.
    • Added relock_guard to safely relock after an unlock_guard.
  • Bug Fixes
    • Futures now report wait_for/wait_until readiness or exceptions as soon as they occur.
    • Corrected the default description used by sleep_until.
  • Tests
    • Expanded coverage for predicate-based sleeping/waiting, notification edge cases, timeouts, and future readiness.

Walkthrough

Timed suspension APIs now accept move-only predicates and return thread_restart_state. Execution agents evaluate predicates during waits, condition variables propagate them, and future waits use readiness predicates. unlock_guard also gains scoped relocking support.

Changes

Predicate-aware timed suspension

Layer / File(s) Summary
Timed suspension API contracts
libs/core/execution_base/include/hpx/execution_base/agent_base.hpp, libs/core/execution_base/include/hpx/execution_base/agent_ref.hpp, libs/core/threading_base/include/hpx/threading_base/execution_agent.hpp, libs/core/execution_base/include/hpx/execution_base/this_thread.hpp, libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
Timed sleep and condition-variable wait declarations accept move-only predicates and return restart states.
Execution-agent predicate handling
libs/core/threading_base/src/execution_agent.cpp, libs/core/execution_base/src/agent_ref.cpp, libs/core/execution_base/src/this_thread.cpp
Execution agents evaluate predicates during waits, return signaled or timeout, and default waits return timeout.
Condition-variable and future integration
libs/core/synchronization/src/detail/condition_variable.cpp, libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp, libs/core/futures/src/future_data.cpp
Condition-variable waits track reset state and propagate predicates, while future waits stop when shared state becomes ready.
Predicate wait validation
libs/core/execution_base/tests/unit/execution_context.cpp, libs/core/futures/tests/unit/future.cpp, libs/core/synchronization/tests/unit/condition_variable.cpp
Tests cover signaling, move-only predicates, readiness, timeouts, expired waits, spurious notifications, and multiple predicates.

Scoped lock guards

Layer / File(s) Summary
Unlock and relock guard behavior
libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
unlock_guard explicitly deletes copy and move operations, and new relock_guard temporarily relocks an associated lock.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FutureData
  participant ConditionVariable
  participant ExecutionAgent
  participant WaitPredicate
  FutureData->>ConditionVariable: wait_until with readiness predicate
  ConditionVariable->>ExecutionAgent: sleep_until with wait_cond
  ExecutionAgent->>WaitPredicate: evaluate condition
  WaitPredicate-->>ExecutionAgent: true or false
  ExecutionAgent-->>ConditionVariable: signaled or timeout
  ConditionVariable-->>FutureData: wait result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: future waits now return when the shared state becomes ready, including wait_until and wait_for behavior.
Description check ✅ Passed The description is directly related to the change, stating that future waits stop promptly once the shared state becomes ready.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch future_wait_until

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/core/execution_base/tests/unit/execution_context.cpp`:
- Around line 56-64: Return an explicit threads::thread_restart_state::timeout
value from both sleep_for and sleep_until overrides, matching default_agent
behavior and preventing non-void functions from reaching the end without
returning.

In `@libs/core/futures/src/future_data.cpp`:
- Around line 393-400: Update the lambda assigned to wait_cond in
future_data_base::wait_until by adding the explicit empty parameter list,
changing the capture form from [this] to [this](), so it remains compatible with
C++20.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e668afd1-f0dc-405a-9f88-f8edd7c77bc2

📥 Commits

Reviewing files that changed from the base of the PR and between 3cc9c02 and 131f15d.

📒 Files selected for processing (10)
  • libs/core/execution_base/include/hpx/execution_base/agent_base.hpp
  • libs/core/execution_base/include/hpx/execution_base/agent_ref.hpp
  • libs/core/execution_base/src/agent_ref.cpp
  • libs/core/execution_base/src/this_thread.cpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/src/future_data.cpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/threading_base/include/hpx/threading_base/execution_agent.hpp
  • libs/core/threading_base/src/execution_agent.cpp

Comment thread libs/core/execution_base/tests/unit/execution_context.cpp Outdated
Comment thread libs/core/futures/src/future_data.cpp
…de ready

Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
@hkaiser hkaiser force-pushed the future_wait_until branch from 131f15d to 42f4bd0 Compare July 10, 2026 18:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/core/execution_base/include/hpx/execution_base/this_thread.hpp`:
- Around line 78-85: Update the default desc value in this_thread::sleep_until
to identify sleep_until rather than sleep_for, preserving the existing
agent().sleep_until call and diagnostics behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fdc8c829-1508-4707-95a7-d40b2ea453ad

📥 Commits

Reviewing files that changed from the base of the PR and between 42f4bd0 and c1ad7b2.

📒 Files selected for processing (4)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp

Comment thread libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
@hkaiser hkaiser force-pushed the future_wait_until branch from c1ad7b2 to 8201c2b Compare July 10, 2026 21:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
libs/core/synchronization/src/detail/condition_variable.cpp (1)

250-272: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Non-predicate wait_until duplicates the predicate overload; delegate instead.

This body is identical to the predicate overload except for the always-false predicate. Delegating keeps the two in sync and is behavior-preserving: with an always-false predicate s is signaled on notify (f.ctx_ cleared) and timeout on timer expiry (f.ctx_ still set), yielding the same result as the current f.ctx_ ? timeout : signaled.

♻️ Proposed delegation
     threads::thread_restart_state condition_variable::wait_until(
         std::unique_lock<mutex_type>& lock,
         hpx::chrono::steady_time_point const& abs_time,
-        char const* /* description */, error_code& /* ec */)
-    {
-        HPX_ASSERT_OWNS_LOCK(lock);
-
-        // enqueue the request and block this thread
-        auto const this_ctx = hpx::execution_base::this_thread::agent();
-        queue_entry f(this_ctx, &queue_);
-        queue_.push_back(f);
-
-        reset_queue_entry r(f);
-
-        {
-            // suspend this thread
-            unlock_guard<std::unique_lock<mutex_type>> ul(lock);
-            this_ctx.sleep_until(abs_time.value(), [] { return false; });
-        }
-
-        return f.ctx_ ? threads::thread_restart_state::timeout :
-                        threads::thread_restart_state::signaled;
-    }
+        char const* description, error_code& ec)
+    {
+        return wait_until(lock, abs_time,
+            hpx::move_only_function<bool()>([] { return false; }), description,
+            ec);
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/core/synchronization/src/detail/condition_variable.cpp` around lines 250
- 272, Refactor the non-predicate condition_variable::wait_until overload to
delegate to the predicate-based wait_until overload using an always-false
predicate, preserving its existing timeout/signaled behavior. Remove the
duplicated queueing and sleep logic from this overload while forwarding the
lock, abs_time, description, and error_code arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@libs/core/synchronization/src/detail/condition_variable.cpp`:
- Around line 250-272: Refactor the non-predicate condition_variable::wait_until
overload to delegate to the predicate-based wait_until overload using an
always-false predicate, preserving its existing timeout/signaled behavior.
Remove the duplicated queueing and sleep logic from this overload while
forwarding the lock, abs_time, description, and error_code arguments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94716dff-06a9-43d0-ade5-fa0ebd5703c0

📥 Commits

Reviewing files that changed from the base of the PR and between c1ad7b2 and 8201c2b.

📒 Files selected for processing (7)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp

@hkaiser hkaiser force-pushed the future_wait_until branch from 8201c2b to 7a913ea Compare July 11, 2026 00:38
@StellarBot

Copy link
Copy Markdown
Collaborator
Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T00:38:25+00:00
HPX Commit0eeca860e85590
Datetime2026-03-09T09:15:24.034803-05:002026-07-10T22:50:44.337746-05:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Envfile

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T00:38:25+00:00
HPX Commit0eeca860e85590
Datetime2026-03-09T09:17:15.638328-05:002026-07-10T22:52:48.525849-05:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Envfile

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)=--
Stream Benchmark - Scale(=)---
Stream Benchmark - Triad(=)---
Stream Benchmark - Copy+++++++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T18:50:37+00:002026-07-11T00:38:25+00:00
HPX Commitba89f5d0e85590
Datetime2026-03-09T17:49:10.837937-05:002026-07-10T22:53:33.657727-05:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Envfile

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@StellarBot

Copy link
Copy Markdown
Collaborator
Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T13:59:23+00:00
HPX Commit0eeca8648725ea
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T09:15:24.034803-05:002026-07-11T09:07:52.818593-05:00
Clusternamerostamrostam
Envfile

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T13:59:23+00:00
HPX Commit0eeca8648725ea
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T09:17:15.638328-05:002026-07-11T09:10:00.322936-05:00
Clusternamerostamrostam
Envfile

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)---
Stream Benchmark - Scale(=)---
Stream Benchmark - Triad(=)----
Stream Benchmark - Copy(=)+++++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T18:50:37+00:002026-07-11T13:59:23+00:00
HPX Commitba89f5d48725ea
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T17:49:10.837937-05:002026-07-11T09:10:45.409882-05:00
Clusternamerostamrostam
Envfile

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@hkaiser hkaiser force-pushed the future_wait_until branch from fa8e4e3 to 418bcae Compare July 11, 2026 14:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
libs/core/synchronization/src/detail/condition_variable.cpp (1)

276-300: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Return signaled when the wait predicate ends the suspension.

When wait_cond becomes true, sleep_until reports signaled, but f.ctx_ remains set because no notification removed the entry. Line 298 therefore incorrectly converts the predicate wake-up to timeout.

Proposed restart-state mapping
-        return f.ctx_ || s == threads::thread_restart_state::timeout ?
+        return s == threads::thread_restart_state::timeout ?
             threads::thread_restart_state::timeout :
             threads::thread_restart_state::signaled;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/core/synchronization/src/detail/condition_variable.cpp` around lines 276
- 300, Update condition_variable::wait_until so a sleep_until result of signaled
is returned as signaled even when f.ctx_ remains set. Preserve timeout handling
for an actual timeout, and keep notification-driven wake-ups mapped to the
existing signaled behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp`:
- Around line 358-368: Update both predicate-based condition-variable wait
paths, including the overload around wait_until and the corresponding path near
the second occurrence, so user pred is evaluated while the caller’s lock remains
held. Do not forward pred through the lower predicate-aware
wait_until/sleep_until path after constructing unlock_guard; instead use the
non-predicate wait and recheck pred under the lock, while preserving the
existing inner-lock ordering and timeout behavior.
- Around line 436-440: Update the timed stop-token wait path around
wait_until_pred to forward the original predicate instead of passing the lvalue
copy. Ensure wait_until_pred and the subsequent wait layer preserve the same
predicate object, supporting move-only predicates and retaining state changes
from stateful predicates.

In `@libs/core/synchronization/src/detail/condition_variable.cpp`:
- Around line 250-274: The condition_variable::wait_until predicate must stop
polling the non-atomic queue_entry field f.ctx_ while the lock is released. Add
or reuse an atomic notification marker in queue_entry, set it before
notify_one/notify_all clear ctx_, and have the sleep_until predicate poll that
marker; update the final timeout/signaled decision to use the marker
consistently.

---

Outside diff comments:
In `@libs/core/synchronization/src/detail/condition_variable.cpp`:
- Around line 276-300: Update condition_variable::wait_until so a sleep_until
result of signaled is returned as signaled even when f.ctx_ remains set.
Preserve timeout handling for an actual timeout, and keep notification-driven
wake-ups mapped to the existing signaled behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 53282baf-6814-4f64-a633-a814d2113840

📥 Commits

Reviewing files that changed from the base of the PR and between fa8e4e3 and 418bcae.

📒 Files selected for processing (7)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
🚧 Files skipped from review as they are similar to previous changes (5)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp

Comment thread libs/core/synchronization/src/detail/condition_variable.cpp
@StellarBot

Copy link
Copy Markdown
Collaborator
Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T14:36:27+00:00
HPX Commit0eeca8661738f7
Clusternamerostamrostam
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T09:15:24.034803-05:002026-07-11T09:47:12.458401-05:00

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T14:36:27+00:00
HPX Commit0eeca8661738f7
Clusternamerostamrostam
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T09:17:15.638328-05:002026-07-11T09:49:20.005234-05:00

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)---
Stream Benchmark - Scale(=)---
Stream Benchmark - Triad(=)----
Stream Benchmark - Copy(=)++++++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T18:50:37+00:002026-07-11T14:36:27+00:00
HPX Commitba89f5d61738f7
Clusternamerostamrostam
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T17:49:10.837937-05:002026-07-11T09:50:05.360637-05:00

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@hkaiser hkaiser force-pushed the future_wait_until branch from 418bcae to 17397ac Compare July 11, 2026 18:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp (1)

23-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Forward declaration's template parameter name diverges from the definition.

The forward declaration uses Lockable while the actual definition at line 69 uses Lock. Not a functional issue since parameter names in declarations are independent, but keeping them consistent aids readability.

✏️ Suggested consistency fix
-    HPX_CXX_CORE_EXPORT template <typename Lockable>
+    HPX_CXX_CORE_EXPORT template <typename Lock>
     class relock_guard;

Also applies to: 69-70

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp` around
lines 23 - 24, Align the template parameter name in the relock_guard forward
declaration with its definition by changing Lockable to Lock, while leaving the
class behavior and declaration structure unchanged.
libs/core/synchronization/src/detail/condition_variable.cpp (1)

259-286: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: the no-predicate overload largely duplicates the predicate overload.

Both overloads differ only in the sleep_until predicate and are otherwise identical (enqueue, reset_queue_entry, restart-state mapping). The no-predicate version is equivalent to delegating to the predicate overload with an always-false predicate. Consider consolidating to reduce drift between the two paths (weigh against the small move_only_function allocation on this hot path).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/core/synchronization/src/detail/condition_variable.cpp` around lines 259
- 286, Consolidate the no-predicate condition_variable::wait_until
implementation by delegating to the existing predicate overload with an
always-false predicate, preserving the enqueue, reset, and restart-state
behavior. Confirm this does not introduce an unacceptable move_only_function
allocation on this hot path; if it does, retain the separate implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@libs/core/synchronization/src/detail/condition_variable.cpp`:
- Around line 259-286: Consolidate the no-predicate
condition_variable::wait_until implementation by delegating to the existing
predicate overload with an always-false predicate, preserving the enqueue,
reset, and restart-state behavior. Confirm this does not introduce an
unacceptable move_only_function allocation on this hot path; if it does, retain
the separate implementation.

In `@libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp`:
- Around line 23-24: Align the template parameter name in the relock_guard
forward declaration with its definition by changing Lockable to Lock, while
leaving the class behavior and declaration structure unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7586e4a7-d6f9-401d-ba12-16c41dac8d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 418bcae and 17397ac.

📒 Files selected for processing (8)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
🚧 Files skipped from review as they are similar to previous changes (6)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp

@StellarBot

Copy link
Copy Markdown
Collaborator
Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Commit0eeca8646a61ca
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T18:17:31+00:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T09:15:24.034803-05:002026-07-11T13:26:55.237483-05:00
Clusternamerostamrostam
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Commit0eeca8646a61ca
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T18:17:31+00:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T09:17:15.638328-05:002026-07-11T13:29:02.734753-05:00
Clusternamerostamrostam
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)(=)--
Stream Benchmark - Scale(=)---
Stream Benchmark - Triad(=)----
Stream Benchmark - Copy(=)++++++

Info

PropertyBeforeAfter
HPX Commitba89f5d46a61ca
HPX Datetime2026-03-09T18:50:37+00:002026-07-11T18:17:31+00:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T17:49:10.837937-05:002026-07-11T13:29:47.979830-05:00
Clusternamerostamrostam
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@hkaiser hkaiser force-pushed the future_wait_until branch 2 times, most recently from d1e4604 to 10c7adb Compare July 11, 2026 18:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/core/futures/tests/unit/future.cpp`:
- Around line 478-527: In test_wait_for_returns_as_soon_as_value_is_set and
test_wait_until_returns_as_soon_as_value_is_set, tighten the elapsed-time
assertions to use a short timeout and CI-tolerant bound appropriate for the
100-millisecond fulfillment, rather than allowing nearly five seconds. Apply the
same adjustment to the additional readiness timing test covering the indicated
range, while preserving the existing status and value assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2683699c-79a1-4b6a-b3d4-d2fa3348bdc2

📥 Commits

Reviewing files that changed from the base of the PR and between d1e4604 and 10c7adb.

📒 Files selected for processing (8)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
🚧 Files skipped from review as they are similar to previous changes (7)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/synchronization/src/detail/condition_variable.cpp

Comment thread libs/core/futures/tests/unit/future.cpp
@hkaiser hkaiser force-pushed the future_wait_until branch from 10c7adb to 945f667 Compare July 11, 2026 19:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp (1)

118-123: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a default-description convenience overload for symmetry.

The plain wait_until gets a convenience overload with a default description (Lines 124-131), but this new predicate-taking overload has no equivalent — callers must always supply description explicitly. Minor API asymmetry; worth a short overload if predicate-based callers elsewhere in the stack would benefit from a default description.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp`
around lines 118 - 123, Add a convenience overload alongside the
predicate-taking wait_until declaration that omits description and forwards to
the existing overload with the established default description, preserving all
other parameters and error_code behavior. Keep the current overload unchanged
and mirror the nearby plain wait_until overload’s API pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp`:
- Around line 118-123: Add a convenience overload alongside the predicate-taking
wait_until declaration that omits description and forwards to the existing
overload with the established default description, preserving all other
parameters and error_code behavior. Keep the current overload unchanged and
mirror the nearby plain wait_until overload’s API pattern.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bbc9df83-87a0-4ed8-8622-9cf9e98018aa

📥 Commits

Reviewing files that changed from the base of the PR and between 10c7adb and 945f667.

📒 Files selected for processing (8)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/include/hpx/synchronization/detail/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
🚧 Files skipped from review as they are similar to previous changes (7)
  • libs/core/execution_base/include/hpx/execution_base/this_thread.hpp
  • libs/core/execution_base/tests/unit/execution_context.cpp
  • libs/core/thread_support/include/hpx/thread_support/unlock_guard.hpp
  • libs/core/synchronization/include/hpx/synchronization/condition_variable.hpp
  • libs/core/synchronization/src/detail/condition_variable.cpp
  • libs/core/futures/tests/unit/future.cpp
  • libs/core/synchronization/tests/unit/condition_variable.cpp

@hkaiser hkaiser force-pushed the future_wait_until branch from 945f667 to de2cf58 Compare July 11, 2026 20:08
Implemented from a Change Stack AI coding task.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
@hkaiser hkaiser force-pushed the future_wait_until branch from de2cf58 to d478f99 Compare July 11, 2026 22:40
@StellarBot

Copy link
Copy Markdown
Collaborator
Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Commit0eeca86771f71d
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T22:40:18+00:00
Clusternamerostamrostam
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T09:15:24.034803-05:002026-07-11T21:04:32.280375-05:00

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Commit0eeca86771f71d
HPX Datetime2026-03-09T14:08:29+00:002026-07-11T22:40:18+00:00
Clusternamerostamrostam
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T09:17:15.638328-05:002026-07-11T21:06:39.731541-05:00

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)(=)--
Stream Benchmark - Scale(=)---
Stream Benchmark - Triad(=)----
Stream Benchmark - Copy(=)++++++

Info

PropertyBeforeAfter
HPX Commitba89f5d771f71d
HPX Datetime2026-03-09T18:50:37+00:002026-07-11T22:40:18+00:00
Clusternamerostamrostam
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Envfile
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T17:49:10.837937-05:002026-07-11T21:07:24.832216-05:00

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants