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

summarysize is incorrect for small union types #33675

Closed
cstjean opened this issue Oct 25, 2019 · 3 comments · Fixed by #33713
Closed

summarysize is incorrect for small union types #33675

cstjean opened this issue Oct 25, 2019 · 3 comments · Fixed by #33713
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@cstjean
Copy link
Contributor

cstjean commented Oct 25, 2019

julia> Base.summarysize(Vector{Union{Float64, Missing}}(undef, 1000))
8040

julia> Base.summarysize(Vector{Float64}(undef, 1000))
8040

Can that possibly be right? It seems that it's not counting the extra type bit vector?

@cstjean
Copy link
Contributor Author

cstjean commented Oct 25, 2019

In fact, for sufficiently large vectors, it's non-deterministic!

julia> vec = vcat(missing, ones(100000));

julia> Base.summarysize(vec)
1600048

julia> Base.summarysize(vec)
1462016

julia> Base.summarysize(vec)
1600048

julia> Base.summarysize(vec)
1448096

julia> Base.summarysize(vec)
1600048

julia> Base.summarysize(vec)
1458480

The docstring says it provides a "lower bound", so technically the output might be correct, but that really looks like a bug somewhere.

@Keno Keno added the bug Indicates an unexpected problem or unintended behavior label Oct 26, 2019
@JeffBezanson
Copy link
Member

JeffBezanson commented Oct 29, 2019

The first issue was fixed by #32886

@JeffBezanson JeffBezanson self-assigned this Oct 29, 2019
@JeffBezanson
Copy link
Member

JeffBezanson commented Oct 29, 2019

The changing result is due to GC --- the value is smaller in trials where GC ran. The summarysize code is pulling out each element and boxing it, then using the addresses to see how many boxes there are. But since those are temporaries, if GC runs they get re-used. But that shouldn't happen since the boxes are unnecessary. I'll fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants