-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Very slow image grabs due to obsolete pure Python msgpack #3333
Comments
I tested this and I'm not seeing any Did the |
Can you try with Python 3.8? That's the version I used. Regarding Python 2, the README does say that fallback.py may be used in case Python 2 is used; however, there are a larger set of circumstances where fallback.py will be used, including anytime there's an ImportError import _cmsgpack: |
Encountered the same issue that @patrickmineault has found. On Windows 10 with:
Once I make a request through simGetImages() with pixels_as_float set to True, the response time becomes two orders of magnitude slower (0.06s vs. 8s). And also, as discussed by @patrickmineault it seems to be an issue of the msgpack-rpc-python package, because, when debugging the AirSim code, the float image finishes copy the pixel long before the Python client receives the response. The solution is exactly as @patrickmineault has suggested. First uninstall msgpack-rpc-python and msgpack-python. Then install the latest msgpack with (check out here) pip install msgpack Check the installation by Then clone https://github.com/tbelhalfaoui/msgpack-rpc-python/tree/fix-msgpack-dep. Remember to checkout the branch Then modify the client.py file of AirSim Python client. Change the class VehicleClient:
def __init__(self, ip = "", port = 41451, timeout_value = 3600):
if (ip == ""):
ip = "127.0.0.1"
# self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port), timeout = timeout_value, pack_encoding = 'utf-8', unpack_encoding = 'utf-8')
self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port), timeout = timeout_value) Upon these modifications, the execution of the AirSim Python client is mush faster. Basically the same speed with pixels_as_float set to be False. |
I tested this again with #3889, and am getting the same performance with changing the msgpack library, ~36 FPS with Blocks binary for default camera. Some more details - Ubuntu 18.04
Normal
Will need to test further whether |
@rajat2004 did you find any solution to speed it up? i am also facing the same issue |
Bug report
What's the issue you encountered?
AirSim's python bindings require
msgpack-rpc-python
, which depends on an obsolete version ofmsgpack
(related issue: #3251). That old version of msgpack doesn't compile, so it falls back to a pure Python implementation which is very slow - in my workflow, more than half the time is spent in msgpack rather than, e.g. rendering.Settings
How can the issue be reproduced?
conda create --name test python=3.8
conda activate test
pip install airsim
test.py
with the following code:python -m cProfile test.py
. Scroll down and you will see many calls tofallback.py
, e.g.:181988/36 0.202 0.000 0.884 0.025 fallback.py:380(_fb_unpack)
fallback.py
is the pure Python fallback from msgpack: https://github.com/msgpack/msgpack-python/blob/master/msgpack/fallback.py.A quick way of figuring out if msgpack is installed with compiled bindings:
from msgpack import _cmsgpack
. If it's not, things are going to be real slow.Include full error message in text form
No errors, just slowness
Workaround
I found a nasty workaround. I uninstalled airsim, msgpack-python and mspack-rpc-python. I then pip installed from git this upgraded fork of msgpack-rpc-python: https://github.com/tbelhalfaoui/msgpack-rpc-python/tree/fix-msgpack-dep. Then I git cloned airsim, locally installed in editable mode, and I patched
client.py
to remove the input and output encodings (those were removed in msgpack 1.0). Now my pipeline is much much faster.What's better than filing an issue? Filing a pull request :).
The text was updated successfully, but these errors were encountered: