nschloe / tuna

:fish: Python profile viewer
GNU General Public License v3.0
1.38k stars 33 forks source link

Broken Pipe #102

Open anklebreaker opened 3 years ago

anklebreaker commented 3 years ago

Quick question, was getting a broken pipe message when running the tuna command. The tab opens up in browser but is unable to connect. Any idea on the cause?

Exception happened during processing of request from ('127.0.0.1', 63304)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/server.py", line 415, in handle_one_request
    method()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tuna/main.py", line 64, in do_GET
    self.wfile.write(content)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 799, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe

Running on MacOS Catalina, Python 3.8 and Chrome

nschloe commented 3 years ago

No idea.

zodman commented 3 years ago

I have a fat project in django what take long time to start ... i generate the profile and tuna cannot open...

http://transfer.sh/1DKbkv6/cprofile.out

I generate the HTML files and the output was 2GB of HTML the unique tool it could open is cprofilev

gabrielfougeron commented 3 years ago

Hi. FYI, i got the same error as @anklebreaker running on wsl2 Windows11

notAlex2 commented 3 years ago

I'm getting a similar error while using tuna 0.5.9 + python3.8 + Chrome 93.0.4577.63 + Ubuntu 18.04:

~$tuna out.cprofile 
Starting httpd on port 8000
127.0.0.1 - - [22/Oct/2021 11:40:29] "GET / HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53870)
Traceback (most recent call last):
  File "/usr/lib/python3.8/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.8/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.8/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib/python3.8/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/usr/lib/python3.8/http/server.py", line 415, in handle_one_request
    method()
  File "/home/apeplowski/envs/py38_tf2_env/lib/python3.8/site-packages/tuna/main.py", line 53, in do_GET
    self.wfile.write(render(data, prof_filename).encode())
  File "/usr/lib/python3.8/socketserver.py", line 826, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
127.0.0.1 - - [22/Oct/2021 11:42:03] "GET /static/tuna.css HTTP/1.1" 200 -
127.0.0.1 - - [22/Oct/2021 11:42:03] "GET /static/bootstrap.min.css HTTP/1.1" 200 -
127.0.0.1 - - [22/Oct/2021 11:42:03] "GET /static/favicon256.png HTTP/1.1" 200 -
gjohnston9 commented 2 years ago

Same here :( My .prof file is 1.9M, not sure if this could be caused by too much data

vschoener commented 2 years ago

Same error on my side. 2.9 MB for the file. Seems maybe too complicated to handle using a request?

martijnthe commented 2 years ago

I came to tune after hitting this limitation of snakeviz -- thanks for filing that issue btw!

When loading a large-ish .prof file (2.9MiB), the browser tab crashes (out of memory?). I think the "Broken Pipe" is a consequence of the tab crashing, not the cause of it. FWIW, I tried it both with a recent Brave and Firefox. Same thing in both browsers.

A smaller .prof file (1MiB) loads OK, although it seems to bog down the browser quite a bit.

Tuna: version 0.5.11 Brave: Version 1.39.122 Chromium: 102.0.5005.115 (Official Build) Python 3.8.12

gubenkoved commented 11 months ago

Unfortunately unusable with my sample on 2.3 MiB of traces with the same symptom -- browser tab crashing and breaking the connection. It is able to render another sample with 700 KiB of data though.

Tuna: 0.5.11
Python: 3.10.6
OS: macOS 13.6.1
bio-la commented 6 months ago

same issue here, i got files of ~3MB. any idea how to get around this?

NoAnyLove commented 5 months ago

I think this issue is caused by the giant graph data generated in the HTML file. I tried with a 2.1MiB trace file and the browser crashed. I used wget to download the page directly, and the downloaded HTML file is as huge as 663MiB. It has 64 lines and one of them is an incredibly long x-icicle data. Even vim is struggling with opening this file.

Not sure if format the x-icicle data into multiple-lines would help with this issue, or probably it needs interactive partial loading like snakeviz?