question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

numba makes sgp4 slower

See original GitHub issue

I still didn’t have time to craft a proper reproducible example, but we observed a noticeable slowdown when using sgp4 2.2, which is entirely consistent with this observation by @rirze:

In my course of using this library, I have found Numba to be increasing my runtimes for the sgp4 routine, rather than decreasing it. […] In fact, on my machine, Numba compilation increases sgp4 runtime by 2-3x! (Ubuntu 18.04 Windows Subsystem Linux, Python 3.6.4)

We are also observing a large number of warnings:

tests/test_full_pipeline.py::test_orbit_assigners_are_recovered
  /home/juanlu/.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py:1698: NumbaWarning: 
  Compilation is falling back to object mode WITH looplifting enabled because Function "sgp4" failed type inference due to: Untyped global name '_dpper': cannot determine Numba type of <class 'function'>
  
  File "../../../../.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py", line 1838:
  def sgp4(satrec, tsince, whichconst=None):
      <source elided>
  
           ep, xincp, nodep, argpp, mp = _dpper(
           ^
  
    @jit(cache=True)

tests/test_full_pipeline.py::test_orbit_assigners_are_recovered
  /home/juanlu/.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py:1698: NumbaWarning: 
  Compilation is falling back to object mode WITHOUT looplifting enabled because Function "sgp4" failed type inference due to: Untyped global name '_dpper': cannot determine Numba type of <class 'function'>
  
  File "../../../../.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py", line 1838:
  def sgp4(satrec, tsince, whichconst=None):
      <source elided>
  
           ep, xincp, nodep, argpp, mp = _dpper(
           ^
  
    @jit(cache=True)

tests/test_full_pipeline.py::test_orbit_assigners_are_recovered
  /home/juanlu/.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/numba/object_mode_passes.py:178: NumbaWarning: Function "sgp4" was compiled in object mode without forceobj=True, but has lifted loops.
  
  File "../../../../.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py", line 1700:
  #@jit
  def sgp4(satrec, tsince, whichconst=None):
  ^
  
    state.func_ir.loc))

tests/test_full_pipeline.py::test_orbit_assigners_are_recovered
  /home/juanlu/.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/numba/object_mode_passes.py:187: NumbaDeprecationWarning: 
  Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.
  
  For more information visit http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit
  
  File "../../../../.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py", line 1700:
  #@jit
  def sgp4(satrec, tsince, whichconst=None):
  ^
  
    warnings.warn(errors.NumbaDeprecationWarning(msg, state.func_ir.loc))

tests/test_full_pipeline.py::test_orbit_assigners_are_recovered
  /home/juanlu/.pyenv/versions/3.7.4/envs/mbp37_4/lib/python3.7/site-packages/sgp4/propagation.py:1698: NumbaWarning: Cannot cache compiled function "sgp4" as it uses lifted loops
    @jit(cache=True)

sgp4 own tests do take much longer now, but this is somewhat to be expected because the compilation step takes some time:

$ time python -m sgp4.tests 2> /dev/null 

real	0m12,655s
user	0m12,631s
sys	0m0,537s
$ export NUMBA_DISABLE_JIT=1
$ time python -m sgp4.tests
...............
----------------------------------------------------------------------
Ran 15 tests in 0.080s

OK

real	0m0,678s
user	0m0,724s
sys	0m0,228s

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
brandon-rhodescommented, Feb 4, 2020

I have just released 2.3 with the Numba experiment removed. A normal pip install should now give you a correctly functioning version. Let me know if you notice any regression.

0reactions
astrojuanlucommented, Dec 7, 2020

…I can promise something 😃 #76

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why numba is slower than pure python in my code?
I think the reason that your Numba code runs slower is because of next things: Probably you measure time of first run of...
Read more >
Acceptable API breakage to support Numba acceleration? #14
While investigating skyfielders/python-skyfield#30 I found a few places where an API break would be necessary to fully accelerate the ...
Read more >
Using Numba works slower than not using it for my Python code
As you can see, execution is almost 60 times slower when using numba which is undesirable.
Read more >
Performance Tips — Numba 0.50.1 documentation
To make it such that only no python mode is used and if compilation fails an exception is raised the decorators @njit and...
Read more >
sgp4 - PyPI
This Python package computes the position and velocity of an earth-orbiting satellite, given the satellite's TLE orbital elements from a source like ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found