mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
Reference counting for direct call submitted tasks (#6514)
Co-authored-by: Zhijun Fu <37800433+zhijunfu@users.noreply.github.com>
This commit is contained in:
co-authored by
Zhijun Fu
parent
b0b6b56bb7
commit
e50aa99be1
+20
-6
@@ -1073,16 +1073,12 @@ cdef class CoreWorker:
|
||||
return output
|
||||
|
||||
def add_object_id_reference(self, ObjectID object_id):
|
||||
cdef:
|
||||
CObjectID c_object_id = object_id.native()
|
||||
# Note: faster to not release GIL for short-running op.
|
||||
self.core_worker.get().AddObjectIDReference(c_object_id)
|
||||
self.core_worker.get().AddLocalReference(object_id.native())
|
||||
|
||||
def remove_object_id_reference(self, ObjectID object_id):
|
||||
cdef:
|
||||
CObjectID c_object_id = object_id.native()
|
||||
# Note: faster to not release GIL for short-running op.
|
||||
self.core_worker.get().RemoveObjectIDReference(c_object_id)
|
||||
self.core_worker.get().RemoveLocalReference(object_id.native())
|
||||
|
||||
def serialize_and_promote_object_id(self, ObjectID object_id):
|
||||
cdef:
|
||||
@@ -1174,6 +1170,24 @@ cdef class CoreWorker:
|
||||
def current_actor_is_asyncio(self):
|
||||
return self.core_worker.get().GetWorkerContext().CurrentActorIsAsync()
|
||||
|
||||
def get_all_reference_counts(self):
|
||||
cdef:
|
||||
unordered_map[CObjectID, pair[size_t, size_t]] c_ref_counts
|
||||
unordered_map[CObjectID, pair[size_t, size_t]].iterator it
|
||||
|
||||
c_ref_counts = self.core_worker.get().GetAllReferenceCounts()
|
||||
it = c_ref_counts.begin()
|
||||
|
||||
ref_counts = {}
|
||||
while it != c_ref_counts.end():
|
||||
object_id = ObjectID(dereference(it).first.Binary())
|
||||
ref_counts[object_id] = {
|
||||
"local": dereference(it).second.first,
|
||||
"submitted": dereference(it).second.second}
|
||||
postincrement(it)
|
||||
|
||||
return ref_counts
|
||||
|
||||
def in_memory_store_get_async(self, ObjectID object_id, future):
|
||||
self.core_worker.get().GetAsync(
|
||||
object_id.native(),
|
||||
|
||||
Reference in New Issue
Block a user