Skip to content

Conversation

@KristofferC
Copy link
Member

@KristofferC KristofferC commented Oct 11, 2020

I completely misjudged the cost of repr on a heavily nested dict:

julia> using BenchmarkTools

julia> Base.parsed_toml("/home/kc/.julia/environments/v1.6/Manifest.toml");

julia> @btime repr(d);
  112.659 ms (32433 allocations: 7.35 MiB)

waaat(!!??).

With that time for repr, we just have to stop propagating the dict to the workers via this method. At least the workers will just parse the toml dict once each.

Noticed by @ianshmean when his parallel precompile PR in Pkg started lagging.

The culprit seems to be

  155 @Base/show.jl:763; show(io::IOBuffer, x::Type)
  ╎    ╎    ╎    ╎    ╎    ╎    155 @Base/show.jl:637; show_typealias(io::IOBuffer, x::Type)
  ╎    ╎    ╎    ╎    ╎    ╎     1   @Base/show.jl:546; make_typealias(x::Type)
 1╎    ╎    ╎    ╎    ╎    ╎    ╎ 1   @Base/reflection.jl:801; uniontypes(x::Any)
  ╎    ╎    ╎    ╎    ╎    ╎     64  @Base/show.jl:551; make_typealias(x::Type)
  ╎    ╎    ╎    ╎    ╎    ╎    ╎ 64  @Base/reflection.jl:98; names
29╎    ╎    ╎    ╎    ╎    ╎    ╎  64  @Base/reflection.jl:98; #names#10
  ╎    ╎    ╎    ╎    ╎    ╎    ╎   35  @Base/sort.jl:735; sort!
  ╎    ╎    ╎    ╎    ╎    ╎    ╎    35  @Base/sort.jl:747; #sort!#8

which I'm guessing is the new fancy type alias printing.

We could perhaps go via TOML.print:

julia> @btime sprint(TOML.print, d);
  2.135 ms (20723 allocations: 994.95 KiB)

or serialization

julia> @btime serialize(IOBuffer(), d)
  409.462 μs (2913 allocations: 200.86 KiB)

but that can be a follow-up (neither of these are available in Base so it isn't trivial to swap).

Edit: Fun fact, names gets called 308 times for this repr.

@KristofferC
Copy link
Member Author

I'll merge this kinda quickly because it's so bad.

@KristofferC KristofferC merged commit 3bfcb74 into master Oct 11, 2020
@KristofferC KristofferC deleted the kc/stop_propagating_toml_dict branch October 11, 2020 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant