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

Minor improvements to nonblocking synchronization. #2272

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Feb 22, 2024

I noticed the call to uv_detach and use of Base.uv_error in JuliaLang/julia#53422, and it also seems better to put a lock around the write to sync_channels to avoid unnecessary threads being created.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (887cc47) 72.05% compared to head (523e1f6) 72.05%.

Files Patch % Lines
lib/cudadrv/synchronization.jl 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2272   +/-   ##
=======================================
  Coverage   72.05%   72.05%           
=======================================
  Files         155      155           
  Lines       14770    14776    +6     
=======================================
+ Hits        10642    10647    +5     
- Misses       4128     4129    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maleadt maleadt merged commit 9251554 into master Feb 22, 2024
1 check passed
@maleadt maleadt deleted the tb/sync_thread_improvements branch February 22, 2024 13:31
# should be safe to assign before threads are running;
# any user will just submit work that makes it block
lock(sync_channel_lock) do
# test and test-and-set
Copy link
Contributor

Choose a reason for hiding this comment

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

TATAS doesn't look safe here to me, since BidirectionalChannel is a struct, not a pointer, so it doesn't have atomic updates in an array. Maybe make it mutable for now? This is the reason for JuliaLang/julia#51495, but we don't have that merged yet. It could also now be an AtomicMemory object, but (a) that is only in v1.11 (b) it doesn't have the public API written yet (c) would incur a lock allocation for every element and every read or write access, which seems undesired here


# we don't know what the size of uv_thread_t is, so reserve enough space
tid = Ref{NTuple{32, UInt8}}(ntuple(i -> 0, 32))
# we don't know what the size of uv_thread_t is, so reserve enough space
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, uv_thead_t is a Csize_t AFAIK, and requires alignment as such, which this does not have

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.

None yet

2 participants