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

thread safety through using task-local storage on non-inplace #86

Merged
merged 3 commits into from
Jun 10, 2022

Conversation

chriselrod
Copy link
Contributor

@chriselrod chriselrod commented Jun 8, 2022

functions; (sc::SimpleChain)(args...) and valgrad(...) w/out bang

Users should avoid using task_local_storage, especially in short lived tasks. If you must use it, try and have long-lived tasks, and communicate with them using channels.

But, probably worth defaulting to correctness for the sake of end users.

These are also the methods that are going to be hit in ForwardDiff and Zygote code that is likely to be multithreaded.

…ns; (sc::SimpleChain)(args...) and valgrad(...) w/out bang
@chriselrod chriselrod requested a review from korsbo June 8, 2022 21:44
@chriselrod
Copy link
Contributor Author

Note that this is actually currently less safe in one respect:
If you have multiple SimpleChains on the sake task, they'll use the same storage.

@codecov
Copy link

codecov bot commented Jun 8, 2022

Codecov Report

Merging #86 (1293d93) into main (80696ec) will increase coverage by 0.00%.
The diff coverage is 66.66%.

@@           Coverage Diff           @@
##             main      #86   +/-   ##
=======================================
  Coverage   71.37%   71.37%           
=======================================
  Files          13       13           
  Lines        2309     2313    +4     
=======================================
+ Hits         1648     1651    +3     
- Misses        661      662    +1     
Impacted Files Coverage Δ
src/chain_rules.jl 20.37% <40.00%> (+1.13%) ⬆️
src/simple_chain.jl 87.02% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80696ec...1293d93. Read the comment docs.

@chriselrod chriselrod merged commit fbebc3e into main Jun 10, 2022
@chriselrod chriselrod deleted the tasklocalstorage branch June 10, 2022 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants