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

WIP: Compile time zone information during package initialization #295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omus
Copy link
Member

@omus omus commented Sep 24, 2020

Fixes #288. Originally TimeZones.jl serialized the compiled time zone information to reduce the time it took to load the package. Julia has had many improvements since then and now it seems feasible to compile the time zone information during package initialization.

Some benchmarking on Julia 1.5.2:

Current master (42bc067)

julia> @time using TimeZones
[ Info: Precompiling TimeZones [f269a46b-ccf7-5d73-abea-4c690281aa53]
  2.637683 seconds (1.21 M allocations: 63.572 MiB, 0.47% gc time)

julia> @time TimeZones.build()
[ Info: Installing 2020a tzdata region data
[ Info: Converting tz source files into TimeZone data
[ Info: Successfully built TimeZones
  2.656608 seconds (4.88 M allocations: 237.398 MiB, 2.32% gc time)

... # New Julia session

julia> @time using TimeZones
  0.157315 seconds (140.87 k allocations: 10.437 MiB)

Current PR:

julia> @time using TimeZones
[ Info: Precompiling TimeZones [f269a46b-ccf7-5d73-abea-4c690281aa53]
  5.969876 seconds (5.88 M allocations: 316.266 MiB, 3.39% gc time)

julia> @time TimeZones.build()
[ Info: Installing 2020a tzdata region data
[ Info: Converting tz source files into TimeZone data
[ Info: Successfully built TimeZones
  1.062082 seconds (2.92 M allocations: 135.474 MiB, 4.64% gc time)

... # New Julia session

julia> @time using TimeZones
  3.014501 seconds (4.80 M allocations: 263.057 MiB, 5.11% gc time)

There is definitely a performance penalty for doing this but it does make the package state more immutable which is something Julia packages in general are moving towards. There are some easy performance gains to be made yet including:

  • Deferring some of the load time to when a time zone is first used
  • Removing unused Serialization dependency and related code
  • Performance optimizations to time zone compiling

@omus omus changed the title WIP: Compile time zone information during package WIP: Compile time zone information during package initialization Sep 24, 2020
@staticfloat
Copy link
Contributor

staticfloat commented Oct 8, 2020

Another possibility is to serialize it out to files stored in scratch spaces, keyed by the Julia version. e.g.

using Scratch

tz_path = joinpath(@get_scratch!("tz-data-$(VERSION.major).$(VERSION.minor)"), ...)

@omus
Copy link
Member Author

omus commented Oct 9, 2020

Another possibility is to serialize it out to files stored in scratch spaces

Great idea. I'll definitely try that out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants