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

Second (vs. third) "using" issue #2590

Open
PallHaraldsson opened this issue Apr 16, 2020 · 5 comments
Open

Second (vs. third) "using" issue #2590

PallHaraldsson opened this issue Apr 16, 2020 · 5 comments
Labels
discussion performance speedups and slowdowns

Comments

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Apr 16, 2020

Nobody has mentioned second plot issues (as in mbaz/Gaston.jl#133), that I recall, or for using as I discovered with Plots.jl (also confirmed in recent but not most recent Julia 1.5):

Longer text on here: https://discourse.julialang.org/t/using-plots-takes-20-seconds-or-more/7061/17?u=palli

What can be done to get minimal "allocations" on second use?

$ julia-1.4.0/bin/julia 

julia> @time using Plots
 10.637071 seconds (8.87 M allocations: 494.417 MiB, 2.51% gc time)

julia> @time using Plots
  1.475938 seconds (1.72 M allocations: 81.089 MiB, 3.81% gc time)

julia> @time using Plots
  0.000227 seconds (246 allocations: 13.312 KiB)

Only mitigated by -O0 but by about 50%:

$ time julia-1.4.0/bin/julia -O0

julia> @time using Plots
  9.048337 seconds (8.87 M allocations: 493.852 MiB, 2.98% gc time)

julia> @time using Plots
  0.772250 seconds (1.72 M allocations: 81.089 MiB, 4.60% gc time)

julia> @time using Plots
  0.000295 seconds (246 allocations: 13.312 KiB)

julia> @time plot(1:3)
  4.354561 seconds (10.44 M allocations: 517.449 MiB, 5.26% gc time)

julia> @time plot(1:3)
  0.001798 seconds (9.85 k allocations: 284.570 KiB)

julia> @time plot(1:3)
  0.002011 seconds (9.85 k allocations: 284.570 KiB)

It seems I ruled out issue with Julia itself or @time.

@PallHaraldsson PallHaraldsson changed the title Second (vs. thrid) "using" issue Second (vs. third) "using" issue Apr 16, 2020
@isentropic
Copy link
Member

I'm just curious but why do you want to using multiple times?

@isentropic
Copy link
Member

This happens to other packages too, I cheked DifferentialEquations for example. Do you think that this issue is Plots.jl specific?

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Apr 30, 2020

It's not Plots.jl specific. I mean, yes, Plots does do something specific, so that this happens for it, but such doesn't happen for all packages (why I ruled out Julia itself). E.g. not for RandomNumbers.jl but does for VectorizedRNG.jl.

I wouldn't do using more than once on purpose (except here for testing), but in general I could see it happening in (large) programs. E.g. you include a package that also does it.

While the number of allocations, and amount of bytes is larger, the speed (of second using) is a bit better on my recent Julia 1.5:

julia> @time using Plots
 10.756484 seconds (18.60 M allocations: 937.382 MiB, 3.84% gc time)

julia> @time using Plots
  0.543384 seconds (1.01 M allocations: 46.835 MiB, 2.70% gc time)

julia> @time using Plots
  0.000324 seconds (366 allocations: 19.484 KiB)

$ julia -O0

julia> @time using Plots  # with -O1 almost as fast, so possibly a better default
  8.539219 seconds (18.60 M allocations: 937.408 MiB, 6.61% gc time)

julia> @time using Plots
  0.288531 seconds (1.01 M allocations: 46.835 MiB, 3.79% gc time)

julia> @time using Plots
  0.000327 seconds (366 allocations: 19.484 KiB)


# since non-default optimization level helps, what does the (very slow) precompilation actually do? I suppose it doesn't fully compile, but what exactly is left out? If the optimization, then above should be equal.

julia> @time using Plots
[ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]
 88.142653 seconds (18.67 M allocations: 947.484 MiB, 0.58% gc time)

@isentropic
Copy link
Member

Let's keep this open, but I do not expect this to be investigated as it perhaps is related to Julia then. I do not think that packages small or large do something wrong that causes this issue.

@BeastyBlacksmith
Copy link
Member

Some insight can be gained from #2676

@t-bltg t-bltg added the performance speedups and slowdowns label Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion performance speedups and slowdowns
Projects
None yet
Development

No branches or pull requests

4 participants