facebookincubator / cinder

Cinder is Meta's internal performance-oriented production version of CPython.
https://trycinder.com
Other
3.49k stars 121 forks source link

numba import error with "-X jit-no-frame" #21

Closed belm0 closed 3 years ago

belm0 commented 3 years ago

(noted that cinder jit is experimental, and jit-no-frame is more experimental) (also, it's silly to have multiple jitters going on, and we want to exorcise numba from our app dependencies)

things are fine with plain jit:

$ python3.8 -X jit
Python 3.8.5+cinder (heads/cinder/3.8:afb6375, May 28 2021, 05:28:52)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from numba.core.types.common import Buffer
>>> Buffer(int, 2, 'C')
buffer(<class 'int'>, 2d, C)

import problem with jit-no-frame:

$ python3.8 -X jit -X jit-no-frame
Python 3.8.5+cinder (heads/cinder/3.8:afb6375, May 28 2021, 05:28:52)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from numba.core.types.common import Buffer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dev/.local/lib/python3.8/site-packages/numba/__init__.py", line 55, in <module>
    import numba.cpython.charseq
  File "/home/dev/.local/lib/python3.8/site-packages/numba/cpython/charseq.py", line 10, in <module>
    from numba.cpython import unicode
  File "/home/dev/.local/lib/python3.8/site-packages/numba/cpython/unicode.py", line 30, in <module>
    from numba.cpython.hashing import _Py_hash_t
  File "/home/dev/.local/lib/python3.8/site-packages/numba/cpython/hashing.py", line 562, in <module>
    'tmp': types.Array(types.uint64, 1, 'C'),
  File "/home/dev/.local/lib/python3.8/site-packages/numba/core/types/abstract.py", line 66, in __call__
    inst = type.__call__(cls, *args, **kwargs)
  File "/home/dev/.local/lib/python3.8/site-packages/numba/core/types/npytypes.py", line 411, in __init__
    super(Array, self).__init__(dtype, ndim, layout, name=name)
  File "/home/dev/.local/lib/python3.8/site-packages/numba/core/types/common.py", line 49, in __init__
    from .misc import unliteral
ModuleNotFoundError: No module named 'numba.cpython.misc'

numba version: 0.51.2

belm0 commented 3 years ago

after disabling the numba dependency, other imports fail oddly under jit-no-frame, so this probably isn't too specific to numba

  File "/home/dev/.local/lib/python3.8/site-packages/asks/sessions.py", line 294, in _handle_exception
    await sock.close()
  File "/home/dev/.local/lib/python3.8/site-packages/anyio/_networking.py", line 211, in close
    from . import move_on_after
ImportError: cannot import name 'move_on_after' from 'asks' (/home/dev/.local/lib/python3.8/site-packages/asks/__init__.py)
jbower-fb commented 3 years ago

As you mentioned no-frame mode is very experimental. In fact we recently concluded we can't quite make it work as-is for our needs. Instead we've shifted to working on -X jit-shadow-frame which seems to get about the same perf wins but has a little bit of extra overhead to keep track of the call-stack for things like unwinding, stack-traces etc. You could try it now, but again this is super experimental and we're not using it in production yet. I'd suggest you check-in again on this in about a month or so.