-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add/remove local ref on ObjectRef construction/finalize, scaffolding …
…for testing reference counts (#126) * add/remove local ref in Ray.jl code * let's try this... * use lambda because of template inference failure * GetAllLocalReferences with wrapped return map type * ref counting tests to exercise add/remove local reference * add local ref false * ==, hash, and show for ObjectID; dont' return ref from Nil * get all reference counts in Ray.jl; specialized deepcopy * use hex string in objectref, finalize not async * restore async to finaliezr and yield in tests * also exercise the task return and construction counting * Update ray_julia_jll/src/wrappers/any.jl Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com> * Update ray_julia_jll/src/wrappers/any.jl Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com> * Update test/object_ref.jl Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com> * attempt to fix segault on tests * Update ray_julia_jll/test/reference_counting.jl Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com> * Update src/object_ref.jl Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com> * Apply suggestions from code review Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com> * the ol' test shuffle * revert un hexing --------- Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
- Loading branch information
1 parent
d275606
commit 6f0db4e
Showing
11 changed files
with
198 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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,31 @@ | ||
@testset "Reference counting" begin | ||
using ray_julia_jll: FromRandom, ObjectID, Hex, AddLocalReference, RemoveLocalReference, | ||
GetAllReferenceCounts, _keys, _getindex, GetCoreWorker | ||
|
||
worker = GetCoreWorker() | ||
# need to convert to hex string because these are just pointers | ||
has_count(oid) = Hex(oid) in Hex.(_keys(GetAllReferenceCounts(worker))) | ||
local_count(oid) = first(_getindex(GetAllReferenceCounts(worker), oid)) | ||
|
||
oid = FromRandom(ObjectID) | ||
|
||
@test !has_count(oid) | ||
|
||
AddLocalReference(worker, oid) | ||
@test has_count(oid) | ||
@test local_count(oid) == 1 | ||
|
||
AddLocalReference(worker, oid) | ||
@test local_count(oid) == 2 | ||
|
||
RemoveLocalReference(worker, oid) | ||
@test local_count(oid) == 1 | ||
|
||
RemoveLocalReference(worker, oid) | ||
@test !has_count(oid) | ||
@test local_count(oid) == 0 | ||
|
||
RemoveLocalReference(worker, oid) | ||
@test !has_count(oid) | ||
@test local_count(oid) == 0 | ||
end |
This file contains 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 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 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 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 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,3 +1,5 @@ | ||
# this runs inside setup_core_worker() | ||
|
||
function serialize_deserialize(x) | ||
io = IOBuffer() | ||
serialize(io, x) | ||
|
This file contains 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 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 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