inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
3k stars 230 forks source link

debugger is very slow with large local variable strings #165

Open jsoref opened 8 years ago

jsoref commented 8 years ago

Consider this script:

def main():
    d=['x',]*100000000
    a='x'*10000000
    b=1+1
    print(b)

main()

set a breakpoint on a= and b=, then run to a=, then run to b=.

I'm fairly certain that this is caused by the Variables area spending a lot of time constructing a string. For large lists as in d=, the Variables area is smart enough to show a slice and allow the user to ask for more. The same sort of intelligence would be incredibly valuable for strings.

It's really painful since the program I'm debugging passes around MBs or GBs of strings including returning them. It's perfectly fast w/o a debugger since they're just a reference.

FWIW, even d is a little slow with this size, one order of magnitude smaller and it isn't even noticeable, so there's room for improvement in arrays too.

asmeurer commented 8 years ago

Try using the stringfier here. It times out for large strings.

Or you can set the stringifier to type, which is less useful, but should always be fast.

jsoref commented 8 years ago

I'm pretty sure that it doesn't help. afaict it isn't running that code path...

jsoref commented 8 years ago
** Unknown exception encountered with possibly-broken third-party extension remotebranches
** which supports versions 3.5 of Mercurial.
** Please disable remotebranches and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.8 (default, Jul  8 2015, 18:13:08) [GCC 4.9.2 20150212 (Red Hat 4.9.2-6)]
** Mercurial Distributed SCM (version 3.6.3+720-3320afb8de54+20160106)
** Extensions loaded: strip, mq, histedit, color, record, rebase, blackbox, remotebranches, evolve, hg-git, pager, shelve
Traceback (most recent call last):
  File "~/hg/crew/hg", line 43, in <module>
    mercurial.dispatch.run()
  File "~/hg/crew/mercurial/dispatch.py", line 54, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "~/hg/crew/mercurial/dispatch.py", line 120, in dispatch
    ret = _runcatch(req)
  File "~/hg/crew/mercurial/dispatch.py", line 198, in _runcatch
    debugmortem[debugger](sys.exc_info()[2])
  File "~/hg/py/lib/python2.7/site-packages/pudb-2015.4.2-py2.7.egg/pudb/__init__.py", line 217, in post_mortem
    dbg.interaction(tb.tb_frame, exc_info)
  File "~/hg/py/lib/python2.7/site-packages/pudb-2015.4.2-py2.7.egg/pudb/debugger.py", line 339, in interaction
    show_exc_dialog=show_exc_dialog)
  File "~/hg/py/lib/python2.7/site-packages/pudb-2015.4.2-py2.7.egg/pudb/debugger.py", line 2059, in call_with_ui
    return f(*args, **kwargs)
  File "~/hg/py/lib/python2.7/site-packages/pudb-2015.4.2-py2.7.egg/pudb/debugger.py", line 2269, in interaction
    self.event_loop()
  File "~/hg/py/lib/python2.7/site-packages/pudb-2015.4.2-py2.7.egg/pudb/debugger.py", line 2229, in event_loop
    keys = self.screen.get_input()
  File "~/hg/py/lib/python2.7/site-packages/urwid/raw_display.py", line 324, in get_input
    self._wait_for_input_ready(self._next_timeout)
  File "~/hg/py/lib/python2.7/site-packages/urwid/raw_display.py", line 526, in _wait_for_input_ready
    fd_list, [], fd_list)
  File "~/hg/pudb/example-stringifier.py", line 60, in <lambda>
    signal.signal(signal.SIGALRM, lambda s, f: timeout(s, f, time))
  File "~/hg/pudb/example-stringifier.py", line 50, in timeout
    raise TimeOutError("Timed out after %d seconds" % time)
__builtin__.TimeOutError: Timed out after 0 seconds
$

The timeout seems to have killed my debugger...