Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix invokelatest bottleneck by using scheduling #50

Merged
merged 1 commit into from
Oct 6, 2017
Merged

Conversation

timholy
Copy link
Owner

@timholy timholy commented Oct 5, 2017

One of the biggest negatives of Revise is that it slows package loading. It turns out that the majority of the bottleneck comes from having the callbacks be made with invokelatest: if you change this line to callback(mod) it dramatically cuts the load time. Unfortunately, with that change, I find that I can't push! a callback to Base.package_callbacks from within the module's __init__ method due to world age problems.

Fortunately, the simple trick in this PR basically fixes the problem.

Demo, starting with julia --startup-file=no so I avoid loading Revise by default (using Julia 0.6, it's much worse on 0.7, 4s vs 13s):

Revise master

julia> using Revise

julia> using Example  # to make sure loading and Revise code is JITted

julia> tstart = time(); using ImageCore, ImageFiltering; yield(); time()-tstart
4.3374011516571045

Without using Revise

julia> using Example

julia> tstart = time(); using ImageCore, ImageFiltering; yield(); time()-tstart
1.8541569709777832

With this branch

julia> using Revise

julia> using Example

julia> tstart = time(); using ImageCore, ImageFiltering; yield(); time()-tstart
2.0255730152130127

CC @vchuravy (in case this trick might help Requires.jl). @vtjnash, could we change those to plain invoke if the module __init__ could use @schedule_for_next_worldage_update push!(Base.package_callbacks, mycallback)?

One of the biggest negatives of Revise is that it slows
package loading. This simple trick basically fixes the problem.
@codecov
Copy link

codecov bot commented Oct 5, 2017

Codecov Report

Merging #50 into master will increase coverage by 0.37%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   84.86%   85.24%   +0.37%     
==========================================
  Files           1        1              
  Lines         304      305       +1     
==========================================
+ Hits          258      260       +2     
+ Misses         46       45       -1
Impacted Files Coverage Δ
src/Revise.jl 85.24% <100%> (+0.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7039126...c6b0bd5. Read the comment docs.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant