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

First pass at improving load times #164

Merged
merged 5 commits into from
Aug 19, 2020
Merged

First pass at improving load times #164

merged 5 commits into from
Aug 19, 2020

Conversation

rofinn
Copy link
Member

@rofinn rofinn commented Aug 18, 2020

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.

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.
src/precompile.jl Outdated Show resolved Hide resolved
src/Memento.jl Outdated Show resolved Hide resolved
src/config.jl Outdated Show resolved Hide resolved
@@ -25,11 +25,11 @@ Ex) "[{level} | {name}]: {msg}" will print message of the form
struct DefaultFormatter <: Formatter
fmt_str::AbstractString
tokens::Vector{Pair{Symbol, Bool}}
output_tz::Dates.TimeZone
output_tz::Union{Dates.TimeZone, Nothing}
Copy link
Member

@oxinabox oxinabox Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the scope of this PR maybe:
I wonder if we should have a timezone in TimeZones.jl called User or UserLocal,
which has the behavour of that having this as nothing does; where it is a caching version of localzone.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was talking to Curtis a bit about it, but I'd have to think more about how it should work and if that has some potential downfalls. Looks like this caching behaviour might be causing issues on Linux.

@codecov
Copy link

codecov bot commented Aug 18, 2020

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%) ⬇️
src/precompile.jl 100.00% <100.00%> (ø)
src/handlers.jl 94.23% <0.00%> (-5.77%) ⬇️
src/records.jl 89.28% <0.00%> (-3.58%) ⬇️
src/loggers.jl 98.19% <0.00%> (-0.91%) ⬇️
src/exceptions.jl 66.66% <0.00%> (+16.66%) ⬆️
... 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
Copy link
Member Author

rofinn commented Aug 19, 2020

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)

@rofinn rofinn merged commit ad32ea8 into master Aug 19, 2020
@rofinn rofinn deleted the rf/precompile branch August 19, 2020 16:37
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.

3 participants