Skip to content

Commit 8dc94b6

Browse files
committed
DTask: Combine UID and TID
1 parent e9210e8 commit 8dc94b6

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/dtask.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,14 @@ function Base.show(io::IO, t::DTask)
107107
end
108108
istask(t::DTask) = true
109109
function Base.convert(::Type{ThunkSyncdep}, task::Dagger.DTask)
110-
tid = lock(Sch.EAGER_ID_MAP) do id_map
111-
id_map[task.uid]
112-
end
113-
ThunkSyncdep(ThunkID(tid, task.thunk_ref))
110+
return ThunkSyncdep(ThunkID(task.uid, isdefined(task, :thunk_ref) ? task.thunk_ref : nothing))
114111
end
115112
ThunkSyncdep(task::DTask) = convert(ThunkSyncdep, task)
116113

117-
const EAGER_ID_COUNTER = Threads.Atomic{UInt64}(1)
118114
function eager_next_id()
119115
if myid() == 1
120-
Threads.atomic_add!(EAGER_ID_COUNTER, one(UInt64))
116+
return UInt64(next_id())
121117
else
122-
remotecall_fetch(eager_next_id, 1)
118+
return remotecall_fetch(eager_next_id, 1)::UInt64
123119
end
124120
end

src/submission.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const UID_TO_TID_CACHE = TaskLocalValue{ReusableCache{Dict{UInt64,Int},Nothing}}
7474
uid, future = payload.uid, payload.future
7575
fargs, options, reschedule = payload.fargs, payload.options, payload.reschedule
7676

77-
id = next_id()
77+
id = Int(uid)
7878

7979
@maybelog ctx timespan_start(ctx, :add_thunk, (;thunk_id=id), (;f=fargs[1], args=fargs[2:end], options, uid))
8080

0 commit comments

Comments
 (0)