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

Make Timer(f, ...) tasks match the stickiness of the parent task. Add spawn kwarg. #56745

Merged
merged 10 commits into from
Jan 6, 2025

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Dec 3, 2024

Currently Timer(f, 1) will create a sticky task and have the same effect as @async in making the parent task also sticky.

I'm not sure if this should be treated as a bugfix (i.e. backport) or a minor behavior change (i.e. introduce in 1.12).

Or just an opt-in new feature, so spawn=false by default.


Now matches parent task stickiness by default.

@IanButterworth IanButterworth added the multithreading Base.Threads and related functionality label Dec 3, 2024
@oscardssmith
Copy link
Member

Why is this a new option? Isn't spawning strictly better?

@IanButterworth
Copy link
Member Author

In case there are use cases where code relies on the behavior. Maybe not needed?

@vchuravy
Copy link
Member

vchuravy commented Dec 6, 2024

Maybe not needed?

Sadly needed.

base/asyncevent.jl Outdated Show resolved Hide resolved
base/asyncevent.jl Outdated Show resolved Hide resolved
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
@IanButterworth IanButterworth changed the title Spawn timer tasks to avoid stickiness Add option to spawn timer tasks to avoid stickiness Dec 6, 2024
@oscardssmith
Copy link
Member

Sadly needed.

why is it needed?

@gbaraldi
Copy link
Member

gbaraldi commented Dec 9, 2024

We should also look for uses of Timer and change them. I also think that this should change the default. Having spooky action at a distance be why someones code is working is not correct. The fact that we sticky is not documented anywhere.

@IanButterworth
Copy link
Member Author

IanButterworth commented Dec 10, 2024

What about spawn if the parent task isn't sticky already?

@IanButterworth
Copy link
Member Author

I'm proposing merging this as opt-in, but once the discussion above is settled, maybe it can still be made opt-out.

@IanButterworth IanButterworth added the merge me PR is reviewed. Merge when all tests are passing label Jan 6, 2025
test/channels.jl Outdated Show resolved Hide resolved
@vchuravy
Copy link
Member

vchuravy commented Jan 6, 2025

What about spawn if the parent task isn't sticky already?

I like this idea.

@IanButterworth IanButterworth removed the merge me PR is reviewed. Merge when all tests are passing label Jan 6, 2025
@IanButterworth IanButterworth changed the title Add option to spawn timer tasks to avoid stickiness Make Timer(f, ...) tasks match the stickiness of the parent task. Add spawn kwarg. Jan 6, 2025
@IanButterworth
Copy link
Member Author

What about spawn if the parent task isn't sticky already?

I like this idea.

Now updated to this.

@IanButterworth IanButterworth merged commit 0787a62 into JuliaLang:master Jan 6, 2025
7 checks passed
@IanButterworth IanButterworth deleted the ib/timer_spawn branch January 7, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants