Skip to content

Commit

Permalink
Fix: Update runtime last-epoch-reached before resuming from sync
Browse files Browse the repository at this point in the history
This race was likely inconsequential for the runtime correctness, but
was observable through the unit test "reaching an epoch will prune
all nodes of the preceding task graph".
  • Loading branch information
fknorr committed Nov 15, 2024
1 parent 2337d7c commit eecbbce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/dry_run_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ void dry_run_executor::thread_main(executor::delegate* const dlg) {
host_object_instances.erase(dhoinstr.get_host_object_id());
},
[&](const epoch_instruction& einstr) {
if(einstr.get_promise() != nullptr) { einstr.get_promise()->fulfill(); }
// Update the runtime last-epoch *before* fulfilling the promise to ensure that the new state can be observed as soon as runtime::sync returns.
// This in turn allows the TDAG to be pruned before any new work is submitted after the epoch.
if(dlg != nullptr) { dlg->epoch_reached(einstr.get_epoch_task_id()); }
if(einstr.get_promise() != nullptr) { einstr.get_promise()->fulfill(); }
shutdown |= einstr.get_epoch_action() == epoch_action::shutdown;
},
[&](const fence_instruction& finstr) {
Expand Down
6 changes: 5 additions & 1 deletion src/live_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,12 @@ void executor_impl::issue(const epoch_instruction& einstr) {
expecting_more_submissions = false;
break;
}
if(einstr.get_promise() != nullptr) { einstr.get_promise()->fulfill(); }

// Update the runtime last-epoch *before* fulfilling the promise to ensure that the new state can be observed as soon as runtime::sync returns.
// This in turn allows the TDAG to be pruned before any new work is submitted after the epoch.
if(delegate != nullptr) { delegate->epoch_reached(einstr.get_epoch_task_id()); }

if(einstr.get_promise() != nullptr) { einstr.get_promise()->fulfill(); }
collect(einstr.get_garbage());

CELERITY_DETAIL_IF_TRACY_ENABLED(FrameMarkNamed("Horizon"));
Expand Down

0 comments on commit eecbbce

Please sign in to comment.