Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] Cancel tasks spawned on compute runtime #3128

Merged
merged 3 commits into from
Oct 31, 2024

Conversation

colin-ho
Copy link
Contributor

@colin-ho colin-ho commented Oct 25, 2024

Spawns compute tasks on joinsets so that they can be cancelled.

@github-actions github-actions bot added the chore label Oct 25, 2024
Copy link

codspeed-hq bot commented Oct 25, 2024

CodSpeed Performance Report

Merging #3128 will not alter performance

Comparing colin/runtime-task-cancel (ab10825) with main (5fc9531)

Summary

✅ 17 untouched benchmarks

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 96.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.00%. Comparing base (5fc9531) to head (ab10825).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/common/runtime/src/lib.rs 97.72% 1 Missing ⚠️
src/daft-local-execution/src/sources/scan_task.rs 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3128      +/-   ##
==========================================
- Coverage   79.00%   79.00%   -0.01%     
==========================================
  Files         634      634              
  Lines       76912    76936      +24     
==========================================
+ Hits        60763    60781      +18     
- Misses      16149    16155       +6     
Files with missing lines Coverage Δ
...-execution/src/intermediate_ops/intermediate_op.rs 82.05% <ø> (ø)
...rc/daft-local-execution/src/sinks/blocking_sink.rs 81.65% <100.00%> (ø)
...c/daft-local-execution/src/sinks/streaming_sink.rs 83.55% <100.00%> (ø)
src/daft-scan/src/glob.rs 88.96% <100.00%> (-0.04%) ⬇️
src/common/runtime/src/lib.rs 90.78% <97.72%> (+2.18%) ⬆️
src/daft-local-execution/src/sources/scan_task.rs 72.50% <0.00%> (ø)

... and 2 files with indirect coverage changes

@colin-ho colin-ho requested a review from samster25 October 29, 2024 06:39
// Spawn it on a joinset on the runtime, such that if the future gets dropped, the task is cancelled
let mut joinset = tokio::task::JoinSet::new();
joinset.spawn_on(future, self.runtime.handle());
async move { joinset.join_next().await.expect("just spawned task") }.boxed()
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't have to box this right? We should avoid the heap allocation if we can here

Copy link
Member

Choose a reason for hiding this comment

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

I also think it would be cleaner to make a struct that holds the joinset and then impl the future trait on that struct.

Similarly to what influx does for the their Job struct
https://github.com/metrico/influxdb_iox/blob/ab17bbc9efbb8568ea5a95ccb9d4bbddd33fc9ea/executor/src/lib.rs#L88

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah good catch no box needed since there's only 1 branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Encapsulated the fut in a RuntimeTask struct

src/common/runtime/src/lib.rs Outdated Show resolved Hide resolved
@colin-ho colin-ho merged commit 8817a08 into main Oct 31, 2024
42 checks passed
@colin-ho colin-ho deleted the colin/runtime-task-cancel branch October 31, 2024 22:00
sagiahrac pushed a commit to sagiahrac/Daft that referenced this pull request Nov 4, 2024
Spawns compute tasks on joinsets so that they can be cancelled.

---------

Co-authored-by: Colin Ho <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants