Skip to content
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

Merged
merged 1 commit into from
Aug 10, 2016

Conversation

JeffBezanson
Copy link
Member

The problem was performance degradation of ObjectIdDict with many deleted items. The table needs to be rehashed after a large number of deletions.

@kshyatt kshyatt added the performance Must go faster label Jul 27, 2016
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)
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

@vtjnash vtjnash Aug 2, 2016

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

Copy link
Member Author

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.

Copy link
Member

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

The problem was performance degradation of ObjectIdDict with many
deleted items. The table needs to be rehashed after a large number
of deletions.
@JeffBezanson JeffBezanson merged commit bba57b0 into master Aug 10, 2016
@tkelman tkelman deleted the jb/fix13529 branch August 10, 2016 04:45
tkelman pushed a commit that referenced this pull request Aug 11, 2016
The problem was performance degradation of ObjectIdDict with many
deleted items. The table needs to be rehashed after a large number
of deletions.

(cherry picked from commit c5e0f47)
ref #17655
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants