-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Description
As discussed in the corresponding Discourse topic, Base.summarysize accounts the union optimization byte twice. Copying from the discussion:
julia> sizeandsummary(x) = sizeof(x), Base.summarysize(x)
julia> 1:100 |> Memory{UInt8} |> sizeandsummary
(100, 116)
julia> 1:100 |> Memory{Union{Nothing,UInt8}} |> sizeandsummary
(200, 316)Where the last number should be 216, not 316.
The relevant code in summarysize.jl is as follows
dsize = sizeof(obj)
T = eltype(obj)
if isbitsunion(T)
# add 1 union selector byte for each element
dsize += length(obj)
endThe line dsize = sizeof(obj) accounts for the union byte array (see above). As Union{Nothing, UInt8} |> Base.isbitsunion (unsurprisingly) returns true, the union byte array is accounted a second time in dsize += length(obj).
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior