invenia / Memento.jl

A flexible logging library for Julia
https://invenia.github.io/Memento.jl/latest
Other
87 stars 14 forks source link

First pass at improving load times #164

Closed rofinn closed 4 years ago

rofinn commented 4 years ago

Due to calling config! and register in the __init__ function our load times were on the order of a few seconds. To address this issue we've cached some default values (e.g., formatter, localzone) and added some precompile logic.

Before:

julia> @time using Memento
  1.289233 seconds (3.60 M allocations: 186.269 MiB, 3.61% gc time)

After:

julia> @time using Memento
  0.672002 seconds (1.13 M allocations: 64.016 MiB, 2.14% gc time)

NOTE: While @time isn't very reliable for times, you can see that we've reduced the number of allocations and amount of memory being allocated by about 1/2 and 1/3 respectively.

Similar to #163, but doesn't require lowering the optimization level.

codecov[bot] commented 4 years ago

Codecov Report

Merging #164 into master will decrease coverage by 1.80%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
- Coverage   96.99%   95.19%   -1.81%     
==========================================
  Files          12       13       +1     
  Lines         333      333              
==========================================
- Hits          323      317       -6     
- Misses         10       16       +6     
Impacted Files Coverage Δ
src/Memento.jl 100.00% <ø> (ø)
src/config.jl 100.00% <ø> (ø)
src/formatters.jl 92.15% <100.00%> (-5.85%) :arrow_down:
src/precompile.jl 100.00% <100.00%> (ø)
src/handlers.jl 94.23% <0.00%> (-5.77%) :arrow_down:
src/records.jl 89.28% <0.00%> (-3.58%) :arrow_down:
src/loggers.jl 98.19% <0.00%> (-0.91%) :arrow_down:
src/exceptions.jl 66.66% <0.00%> (+16.66%) :arrow_up:
... and 1 more

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 6051407...4c092dc. Read the comment docs.

rofinn commented 4 years ago

FWIW, minimizing the changes is a little worse, but not too bad:

julia> @time using Memento
  0.764168 seconds (1.41 M allocations: 78.336 MiB, 2.05% gc time)