JuliaAstro / AstroBase.jl

Interfaces, types, and functions for space science packages
Mozilla Public License 2.0
13 stars 6 forks source link

Refactor XY #26

Closed helgee closed 6 years ago

helgee commented 6 years ago

I did a lot of cleaning up and picked the low-hanging performance fruits but on my machine this is still a lot slower than ERFA. If anybody has suggestions, I am all ears.

Follow-up to #7

benelsen commented 6 years ago

I did some benchmarking on my machine and under 0.7b2 I see about a 21% improvement relative to ERFA (48μs vs. 61μs), under 0.6.4 there's a +7% regression (with a simple sincos monkey patch). Considering how close the 0.7 release is (:crossed_fingers:), additional work on 0.6 probably won't be worth it.

I did implement an IAU2006 CIO based method that's based on the full tables (erfa/sofa drops some coefficients and uses a different precession revision) some time last year and was able to achieve ~25% improvement relative to erfa/sofa. I might have a go and see how it compares under the latest julia versions.

giordano commented 6 years ago

How do you turn a non-registered package to a git repo in Julia 0.7? I obtained it with add https://github.com/JuliaAstro/AstroBase.jl, but now I don't know what to do. develop doesn't seem to like non-registered packages. Is there a way to persuade it?

Edit: never mind, I found the answer at: https://julialang.org/Pkg.jl/latest/#Using-someone-else%27s-project-1

Edit 2: just joking, doesn't work at all. I have no idea how to use this package in Julia 0.7.

giordano commented 6 years ago

Ok, I eventually managed to install the package (it's probably necessary to manually add ~/.julia/dev to LOAD_PATH, I asked for confirmation on discourse). We're probably seeing very different timings, it's necessary to explain what you're measuring:

julia> @benchmark AstroBase.xy06(2.4578265e6, 0.30440190993249416)
BenchmarkTools.Trial: 
  memory estimate:  336 bytes
  allocs estimate:  3
  --------------
  minimum time:     65.831 μs (0.00% GC)
  median time:      66.902 μs (0.00% GC)
  mean time:        68.464 μs (0.00% GC)
  maximum time:     135.642 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1

julia> @benchmark ERFA.xy06(2.4578265e6, 0.30440190993249416)
BenchmarkTools.Trial: 
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     155.015 μs (0.00% GC)
  median time:      156.500 μs (0.00% GC)
  mean time:        161.692 μs (0.00% GC)
  maximum time:     271.066 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1

julia> versioninfo()
Julia Version 0.7.0-beta2.98
Commit 77a4cb5a07 (2018-07-24 21:03 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
helgee commented 6 years ago

I get these results on my machine:

julia> @benchmark AstroBase.xy06(2.4578265e6, 0.30440190993249416)
BenchmarkTools.Trial:
  memory estimate:  336 bytes
  allocs estimate:  3
  --------------
  minimum time:     60.202 μs (0.00% GC)
  median time:      66.325 μs (0.00% GC)
  mean time:        74.365 μs (0.00% GC)
  maximum time:     2.386 ms (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1

julia> @benchmark ERFA.xy06(2.4578265e6, 0.30440190993249416)
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     45.231 μs (0.00% GC)
  median time:      45.904 μs (0.00% GC)
  mean time:        46.634 μs (0.00% GC)
  maximum time:     173.956 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1

julia> versioninfo()
Julia Version 0.7.0-beta2.91
Commit cbb6433669 (2018-07-24 04:22 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin17.7.0)
  CPU: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_PKG_DEVDIR = /Users/helge/projects/julia

I have noticed this before, for some reason ERFA is super fast on the Mac.

helgee commented 6 years ago

I did implement an IAU2006 CIO based method that's based on the full tables (erfa/sofa drops some coefficients and uses a different precession revision) some time last year and was able to achieve ~25% improvement relative to erfa/sofa. I might have a go and see how it compares under the latest julia versions.

@benelsen please do so! I would like to see the results.

codecov-io commented 6 years ago

Codecov Report

Merging #26 into master will increase coverage by 24.06%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #26       +/-   ##
===========================================
+ Coverage   74.58%   98.64%   +24.06%     
===========================================
  Files           5        5               
  Lines         181       74      -107     
===========================================
- Hits          135       73       -62     
+ Misses         46        1       -45
Impacted Files Coverage Δ
src/AstroBase.jl 98.27% <100%> (+0.44%) :arrow_up:
src/bodies/satellites.jl 100% <0%> (+34.88%) :arrow_up:
src/bodies/planets.jl 100% <0%> (+38.46%) :arrow_up:
src/bodies/Bodies.jl 100% <0%> (+66.66%) :arrow_up:
src/bodies/minor.jl 100% <0%> (+75%) :arrow_up:

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 0d42172...cec163e. Read the comment docs.

helgee commented 6 years ago

@prakharcode Please take note of these changes and try to apply some of these tactics to your remaining PRs. When are those rebases incoming? 😉

I will merge this tonight...