-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Threads: add a one time warning to a no-arg nthreads()
#48589
Conversation
base/deprecated.jl
Outdated
@warn """ | ||
In julia 1.9+ which supports threadpools (see [link to docs]) | ||
use of threads should be in the context of which threadpool is going to be used, so `nthreads()` should be | ||
replaced with `nthreads(:default)`, or `nthreads(:interactive)` if interactive threads are requrested.""" maxlog = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not one simple replacement, as many usages must be replaced with task_local_storage instead or dropped entirely. But the replacement is almost never nthreads(:interactive)
replaced with `nthreads(:default)`, or `nthreads(:interactive)` if interactive threads are requrested.""" maxlog = 1 | |
replaced with `nthreads(:default)` or `task_local_storage`, as appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, AFAIU, the "number of threads" is - at least in some cases - a dynamic concept now and potentially/likely(?) even more so in the future. That is, the result of nthreads
(with or without argument) isn't necessarily constant (per Julia session) anymore. This is something that users would need to be informed/warned about as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with both suggestions
This will be quite noisy. Maybe that's a good thing? from the doctests job, due to https://github.com/JuliaData/Parsers.jl/blob/78699fc450ca8c14ac073ddbec28d57cba31bb3c/src/Parsers.jl#L422
Also, it'd be nice if the warning warned about the
|
What about only warn if an interactive threadpool is available? @eval Threads function nthreads()
if Threads.nthreads(:interactive) > 0
@warn """
An interactive threadpool is available, use of threads should be in the context of which threadpool is going to
be used, so `nthreads()` should be replaced with `nthreads(:default)` or `nthreads(:interactive)`""" maxlog = 1
end
return threadpoolsize()
end |
This is silly. Just let people call |
ok. It's not really being deprecated then, right? The manual uses So it seems confusing to say it is (which is what prompted opening this PR) |
The original issue hasn't been addressed. I opened a new one: #48644 |
It seems helpful to communicate the (soft) deprecation of a no-arg
nthreads()
a bit more clearly.re. #48580 (comment)