[ANN] About.jl

We could help out with the other issues. Maybe pointing out were things broke and need fixing could help?

About.jl is a great package, hence I believe having this available for everyone on upcoming versions would be a big plus. I have the feeling more contributors will be willing to step in.

Thanks for the kind words, the main issue is that I still haven’t gone through the headache of backporting some breaking changes in StyledStrings.jl to the compat release, and JuliaSyntaxHighlighting.jl needs to then be updated to account for those, but that may also require JuliaSyntax.jl to make new release now that JuliaSyntaxHighlighting.jl has been updated to support the latest version used in 1.12. All this will happen, it’s just a bit of a headache.

Any help would be lovely, and once it’s sorted I’d be keen to collaborate with people on improving About.jl further :slight_smile:

In the mean time About.jl should be fine with Julia 1.9-1.10 and 1.12+, it’s just 1.11 that sits at the intersection of package versions/compatibility that’s a bit of a headache until the above issues are solved.

1 Like

I’ve just done a spate of bugfixes, released as v1.0.3 :slight_smile: (diff linked below)

8 Likes

Thanks to a particularly egregious bug I managed to slip into the last release :see_no_evil_monkey: we already have v1.0.4!

There are two notable improvements that also come with the bugfix(es):

  • Better guessing whether sizeof will work
  • Showing tag bytes used in inlined unions

Showing the tag byte lets you spot that simply reversing the field cuts the memory required for the Int-flavour of this structure by a third.

This is based on observable heuristics, since it’s not exposed, so this may not always be correct, but it seems to work fairly well :slight_smile:

11 Likes

Thanks for About.jl! The visualization helped me understand Julia’s memory layout for the first time. Super clear and useful for learning how to design data structures.

10 Likes

Thanks a lot, @tecosaur! About.jl became one of the most important packages in my Julia workflow. I can only recommend to every REPL user to put it in startup.jl and append a |> about whenever you want to know something about basically anything there is in Julia.
I am especially thankful for the patience with which you fix bugs whenever I come up with another special case. :slight_smile:

I am still struggling a bit to fully understand the memory layout for the non-isbitstype case.

x has 4 bytes, followed by 4 bytes of padding followed by 8 bytes to the “pointer” to either the UnionAll type Vector or Nothing, where the type information is (somehow) taken from the memory address where the pointer points to.

I haven’t fully understand the Julia source code, but if I got this right, the field access will not use a separate union type tag if jl_field_isptr is true. Otherwise it will go into the jl_is_uniontype branch.

I think isptr is true:

const FieldDesc8 = Tuple{UInt8, UInt8}
MyStruct32{Vector}.layout + sizeof(Base.DataTypeLayout) + sizeof(FieldDesc8) |> Ptr{FieldDesc8} |> unsafe_load |> first |> (x -> x & 0b1) |> Bool

See the definitions of jl_fielddesc8_t and jl_datatype_layout_t.

But if this is correct, doesn’t it mean that Base.summarysize is incorrect, as it returns:

julia> Union{Nothing, Vector} |> Base.SummarySize(IdDict(), Any[], Int[], Union{}, Union{})
16

See the definition of Base.summarysize.

Can anyone with more insights please point out my error or confirm that we should fix Base.summarysize?

2 Likes