-
Notifications
You must be signed in to change notification settings - Fork 58
Refactor transition_range and callers
#291
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #291 +/- ##
==========================================
- Coverage 93.53% 93.51% -0.02%
==========================================
Files 31 32 +1
Lines 1531 1527 -4
==========================================
- Hits 1432 1428 -4
Misses 99 99
Continue to review full report at Codecov.
|
|
Increasing code coverage. Also removed no longer needed imports. |
|
I'll apply my fixups |
7257d9d to
f423b4f
Compare
|
I'm performing some final validation (I definitely need to work on formalizing benchmarks for this package next) and have discovered a regression. On Julia 1.5.1: Current PR: julia> @benchmark collect($(ZonedDateTime(2020, tz"America/Winnipeg"):Hour(1):ZonedDateTime(2021, tz"America/Winnipeg")))
BenchmarkTools.Trial:
memory estimate: 1.27 MiB
allocs estimate: 26381
--------------
minimum time: 1.054 ms (0.00% GC)
median time: 1.361 ms (0.00% GC)
mean time: 1.574 ms (5.58% GC)
maximum time: 9.904 ms (0.00% GC)
--------------
samples: 3175
evals/sample: 1Current master (48fe988): julia> @benchmark collect($(ZonedDateTime(2020, tz"America/Winnipeg"):Hour(1):ZonedDateTime(2021, tz"America/Winnipeg")))
BenchmarkTools.Trial:
memory estimate: 1.81 MiB
allocs estimate: 17588
--------------
minimum time: 787.054 ÎĽs (0.00% GC)
median time: 1.169 ms (0.00% GC)
mean time: 1.978 ms (6.01% GC)
maximum time: 107.202 ms (0.00% GC)
--------------
samples: 2526
evals/sample: 1The increase in allocations is especially interesting. I'll try to get to the bottom of this before proceeding. |
|
I've manged to address the regression and improve things further. It appears that the introduction of a function barrier when using a Current PR (1ed4d09): julia> @benchmark collect($(ZonedDateTime(2020, tz"America/Winnipeg"):Hour(1):ZonedDateTime(2021, tz"America/Winnipeg")))
BenchmarkTools.Trial:
memory estimate: 755.44 KiB
allocs estimate: 8795
--------------
minimum time: 444.120 ÎĽs (0.00% GC)
median time: 683.956 ÎĽs (0.00% GC)
mean time: 859.080 ÎĽs (6.40% GC)
maximum time: 15.121 ms (0.00% GC)
--------------
samples: 5815
evals/sample: 1Current master (48fe988): julia> @benchmark collect($(ZonedDateTime(2020, tz"America/Winnipeg"):Hour(1):ZonedDateTime(2021, tz"America/Winnipeg")))
BenchmarkTools.Trial:
memory estimate: 1.81 MiB
allocs estimate: 17588
--------------
minimum time: 788.836 ÎĽs (0.00% GC)
median time: 998.876 ÎĽs (0.00% GC)
mean time: 1.210 ms (5.79% GC)
maximum time: 25.093 ms (0.00% GC)
--------------
samples: 4128
evals/sample: 1Initially posted benchmarks in the description are still accurate. |
|
Will merge on Monday. I want to get the benchmark suite merged in first |
The previous implementation could return indexes which were not applicable for the local datetime provided. This would require callers of this function to perform additional checks to ensure correct answers were provided.
By setting `start` to `length(tz.transitions)` when `finish >= length(tz.transitions)` we avoid any possible issues with `searchsortedlast` creating a `finish` value `> length(tz.transitions)` which would cause Julia to crash.
Adding the function barrier with FixedTimeZone ended up increasing allocations for this benchmark: ```julia @benchmark collect($(ZonedDateTime(2020, tz"America/Winnipeg"):Hour(1):ZonedDateTime(2021, tz"America/Winnipeg"))) ```
1ed4d09 to
e07eb66
Compare
|
Rebased to be able to use package benchmarks. Here's the results from running locally: Benchmark Report for /Users/omus/.julia/dev/TimeZonesJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTargetBaseline |
|
The slowdown in the |
|
Expected failure on macOS Julia nightly. |
|
Is it worth even benchmarking |
|
The function is still indirectly called by users. Having it benchmarked just makes it easier to track down sources of regressions |
Fixes #289. While looking into ways to avoid having
interpretcreate a vector I realized that improvements totransition_rangecould result in us avoiding having to perform checks later ininterpret. Doing this madetransition_rangeslightly slower but allowed us to use a generator ininterpretwhich avoided allocations. I then found myself wanting to index into a generator to avoid having to construct unnecessaryZonedDateTimes which resulted in me creating theIndexableGenerator(I'll try to make a Base PR for this). Finally, I noticed one more allocation in theZonedDateTime(dt::DateTime, tz::VariableTimeZone ; from_utc::Bool)constructor which I addressed by introducing a function barrier.The end result brings us down to a single allocation for the
ZonedDateTimeand zero allocation when using the isbits type PR.Benchmarks on Julia 1.5.1:
PR:
Current master (48fe988):