-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
fix #13529, slowdown with large number of async sleep
calls
#17655
Conversation
cd68d0f
to
241c7c3
Compare
pop!(t::ObjectIdDict, key::ANY, default::ANY) = | ||
ccall(:jl_eqtable_pop, Any, (Any, Any, Any), t.ht, key, default) | ||
function pop!(t::ObjectIdDict, key::ANY, default::ANY) | ||
val = ccall(:jl_eqtable_pop, Any, (Any, Any, Any), t.ht, key, secret_table_token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we return a Nullable or flag or something, rather than having one particular sentinel value in the system that can't be put into an ObjectIdDict without causing bugs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only really efficient alternative is to return NULL. Would you be comfortable with this:
ptr = ccall(:jl_eqtable_pop, Ptr{Void}, (Any, Any, Any), t.ht, key)
if ptr == C_NULL
return default
end
val = unsafe_pointer_to_objref(ptr)
or is it too risky due to the temporary lack of a root for the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about:
val = ccall(:jl_eqtable_pop, Any, (Any, Any, Any), t.ht, key, default)
val === default || (t.ndel += 1) # this can underestimate `ndel`, but that's ok
return val
it'll be nice when Oscar makes his PR for stack allocating these, so that the obvious solution (return a tuple (val, found)
) is also the most efficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't fix 2-argument pop!
below, which could still incorrectly throw an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but that's an existing failure
241c7c3
to
c5e0f47
Compare
The problem was performance degradation of ObjectIdDict with many deleted items. The table needs to be rehashed after a large number of deletions.