-
Notifications
You must be signed in to change notification settings - Fork 69
More thread-safe GC #529
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
Merged
More thread-safe GC #529
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f7421f8
slightly more thread safe gc
3bcd028
use Channel not Vector and make disable/enable a no-op
1c516d6
Merge remote-tracking branch 'origin/main' into safer-gc
8ca05c9
document GCHook
e230ce9
cannot lock channels on julia 1.6
a36d7c0
revert to using a vector for the queue
a5a2c96
restore test script
f021072
combine queue into a single item
4b3bd65
prefer Fix2 over anonymous function
56aa9bc
update docs
4fdcf31
test multithreaded
9051769
test gc from python
13cc346
add gc tests
45bc71f
fix test
4ec7def
add deprecation warnings
eb6b9f0
safer locking (plus explanatory comments)
a68015e
ref of weakref
ab560ac
SpinLock -> ReentrantLock
cd4db5c
SpinLock -> ReentrantLock
31cd57d
typo: testset -> testitem
73f7eb8
delete redundant test
2a54ca9
remove out of date comment
ca64d21
comment erroneous test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
# TODO | ||
@testitem "GC.gc()" begin | ||
let | ||
pyobjs = map(pylist, 1:100) | ||
Threads.@threads for obj in pyobjs | ||
finalize(obj) | ||
end | ||
end | ||
# The GC sometimes actually frees everything before this line. | ||
# We can uncomment this line if we GIL.@release the above block once we have it. | ||
# Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items) | ||
PythonCall.GC.gc() | ||
@test isempty(PythonCall.GC.QUEUE.items) | ||
end | ||
|
||
@testitem "GC.GCHook" begin | ||
let | ||
pyobjs = map(pylist, 1:100) | ||
Threads.@threads for obj in pyobjs | ||
finalize(obj) | ||
end | ||
end | ||
# The GC sometimes actually frees everything before this line. | ||
# We can uncomment this line if we GIL.@release the above block once we have it. | ||
# Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items) | ||
GC.gc() | ||
@test isempty(PythonCall.GC.QUEUE.items) | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using PythonCall | ||
|
||
# This would consistently segfault pre-GC-thread-safety | ||
let | ||
pyobjs = map(pylist, 1:100) | ||
Threads.@threads for obj in pyobjs | ||
finalize(obj) | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.