Skip to content
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

Does not work well together with tornado #47

Closed
maartenbreddels opened this issue Nov 16, 2020 · 3 comments · Fixed by #48
Closed

Does not work well together with tornado #47

maartenbreddels opened this issue Nov 16, 2020 · 3 comments · Fixed by #48

Comments

@maartenbreddels
Copy link
Contributor

Hi,

I wanted to see if this util could help me profile voila (which is using Tornado), but it gives me this:

$ viztracer -m voila issue/manywidgets.ipynb                                                        dev
[Voila] Using /var/folders/4h/rklzvjwj08170p1nlsntfdkw0000gn/T to store connection files
[Voila] Storing connection files in /var/folders/4h/rklzvjwj08170p1nlsntfdkw0000gn/T/voila_4mz_vpi6.
[Voila] Serving static files from /Users/maartenbreddels/src/QuantStack/voila/voila/static.
[Voila] The port 8866 is already in use, trying another port.
[Voila] The port 8867 is already in use, trying another port.
[Voila] Voilà is running at:
http://localhost:8868/
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
  File "/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/tornado/iostream.py", line 709, in _handle_events
    self._handle_read()
  File "/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/tornado/iostream.py", line 853, in _handle_read
    self._read_from_buffer(pos)
  File "/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/tornado/iostream.py", line 993, in _read_from_buffer
    self._run_read_callback(pos, False)
  File "/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/tornado/iostream.py", line 878, in _run_read_callback
    result = self._consume(size)
  File "/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.7/site-packages/tornado/iostream.py", line 1106, in _consume
    del self._read_buffer[:self._read_buffer_pos]
BufferError: Existing exports of data: object cannot be re-sized
... repeated 10x times....

Is viztracer doing something that could trigger this?

Regards,

Maarten Breddels

@gaogaotiantian
Copy link
Owner

Spent some time on this. viztracer did trigger this behavior, but it's not 100% viztracer's fault. tornado is using some hacky stuff here. The issue is tornado has a local memoryview to the bytearray, which would be fine on its own. However, if there's another reference to the local variable, then the bytearray (in this case, self._read_buffer_pos) will not be re-sizeable. Personally I don't think this is a safe assumption to make on tornado's side, but I won't bore you with the details if you are not interested.

The reason viztracer triggered it is because viztracer kept an unnecessary reference to the whole code object, where it has reference to the local variables, for every function, for performance concern.

However, I think it might be reasonable to reconsider the issue now that it breaks stuff. I would probably change viztracer so it will work with tornado. If so, you should be expecting the change soon :)

@gaogaotiantian
Copy link
Owner

@maartenbreddels I fixed the issue and tested it locally. It's released as 0.10.2. You can just pip install viztracer --upgrade.

If you still have issues with viztracer, please let me know :)

@maartenbreddels
Copy link
Contributor Author

Yeah, works great! Thanks, and already helpful jupyter/jupyter_client#590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants