From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: fgallina@gnu.org (=?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina) Newsgroups: gmane.emacs.bugs Subject: bug#16875: python, comint-mode: Large output makes Emacs freeze Date: Sun, 20 Jul 2014 19:27:46 -0300 Message-ID: <87tx6bhdi5.fsf@gnu.org> References: <530C60A7.1030009@easy-emacs.de> <87bnth4whf.fsf@gnu.org> <53AA5DA5.8060700@easy-emacs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1405895298 28761 80.91.229.3 (20 Jul 2014 22:28:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Jul 2014 22:28:18 +0000 (UTC) Cc: 16875@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 21 00:28:12 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X8zaU-0007qn-IA for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Jul 2014 00:28:10 +0200 Original-Received: from localhost ([::1]:59297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8zaU-0000aW-5O for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Jul 2014 18:28:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8zaQ-0000aP-MV for bug-gnu-emacs@gnu.org; Sun, 20 Jul 2014 18:28:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8zaM-0007kv-Id for bug-gnu-emacs@gnu.org; Sun, 20 Jul 2014 18:28:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8zaM-0007kl-FA for bug-gnu-emacs@gnu.org; Sun, 20 Jul 2014 18:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X8zaM-0002A6-6a for bug-gnu-emacs@gnu.org; Sun, 20 Jul 2014 18:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: fgallina@gnu.org (=?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Jul 2014 22:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16875 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16875-submit@debbugs.gnu.org id=B16875.14058952738290 (code B ref 16875); Sun, 20 Jul 2014 22:28:02 +0000 Original-Received: (at 16875) by debbugs.gnu.org; 20 Jul 2014 22:27:53 +0000 Original-Received: from localhost ([127.0.0.1]:60679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X8zaC-00029e-Nq for submit@debbugs.gnu.org; Sun, 20 Jul 2014 18:27:53 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:56801 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X8za9-00029U-Mx for 16875@debbugs.gnu.org; Sun, 20 Jul 2014 18:27:50 -0400 Original-Received: from 222-99-245-190.fibertel.com.ar ([190.245.99.222]:54175 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1X8za8-00013V-Ci; Sun, 20 Jul 2014 18:27:48 -0400 In-Reply-To: (Stefan Monnier's message of "Wed, 25 Jun 2014 10:26:30 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:91713 Archived-At: Andreas R=C3=B6hler writes: >> Indeed, "pprint" should solve it already. Maybe make that the default? >> IMO looks better anyway. That's changing the Python shell default behavior and I that's out of the scope of python.el. Stefan Monnier writes: >>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D13675 >> To a certain extend. >> There some more operations done by comint, which aren't needed when >> executing Python code from source but may slow down it. > > I expect the main slowdown comes from font-lock. But indeed, it''d be > good to try and profile it to see where the time is spent. > >From profiling, a lot of time spent on font-locking while another bunch is spent at `comint-postoutput-scroll-to-bottom' (default member of `comint-output-filter-functions'). After disabling both, the output is sent pretty quickly and Emacs, while it's a bit slower, it's still responsive. WRT the font-lock slowness I must say I'm not happy the way it's implemented, there should be a better way to just fontify the text after the current prompt. That should avoid any extreme fontification cases. > > If the problem is really in "unneeded comint functionality" (or call it > "bloat"), that's an option, but of course if we don't know where the > performance problem comes, we may end up with the same problem anyway. > Now about the `comint-postoutput-scroll-to-bottom', this alone can also make Emacs be extremely irresponsive (pretty much like with the font-locking enabled). The real culprit of it's slowness is `recenter' function which seems to get really slow with long lines. Here are the elp-results with font-lock disabled (with a smaller sample of output): comint-output-filter 103 29.795948749 = 0.2892810558 comint-postoutput-scroll-to-bottom 104 28.636891969 = 0.2753547304 recenter 104 28.635311547 = 0.2753395341 python-pdbtrack-comint-output-filter-function 104 0.990129131 = 0.0095204724 comint-watch-for-password-prompt 104 0.0924025480 = 0.0008884860 > Maybe comint.el could also be changed so that it "wraps" lines if they > get past some arbitrary maximum length (like 10K chars, for example). > It wouldn't be a great solution, but if the performance sucks really bad > past 10K chars, wrapping the line might be a lesser evil. > Disabling font-lock and avoiding the `recenter' calls works pretty well, so I rather focus on improving those than modifying comint to workaround this. As a final related note, to avoid unnecessary filters, I think the `inferior-python-mode' should set the `comint-output-filter-functions' to a minimum and point users to append custom desired filters using the `inferior-python-mode-hook'. Regards, Fabi=C3=A1n