From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: What makes set-window-buffer slow? Date: Fri, 24 Jun 2016 16:56:47 +0300 Message-ID: <83shw21yhs.fsf@gnu.org> References: <576C04E4.9040000@gmail.com> <576C2054.3020705@gmail.com> <20160623181242.GB4946@acm.fritz.box> <576C2AAA.1090707@gmail.com> <83fus33ekr.fsf@gnu.org> <576C536A.6060503@gmail.com> <83bn2r2i0y.fsf@gnu.org> <576D2895.4020600@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1466778718 7978 80.91.229.3 (24 Jun 2016 14:31:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Jun 2016 14:31:58 +0000 (UTC) Cc: acm@muc.de, emacs-devel@gnu.org, schwab@suse.de To: =?windows-1252?Q?Cl=E9ment?= Pit--Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 24 16:31:57 2016 Return-path: Envelope-to: ged-emacs-devel@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 1bGS9F-0002NC-8b for ged-emacs-devel@m.gmane.org; Fri, 24 Jun 2016 16:31:57 +0200 Original-Received: from localhost ([::1]:43925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGS9E-0007d5-9p for ged-emacs-devel@m.gmane.org; Fri, 24 Jun 2016 10:31:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGRcF-0001wY-Vu for emacs-devel@gnu.org; Fri, 24 Jun 2016 09:57:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGRcB-0007l5-VS for emacs-devel@gnu.org; Fri, 24 Jun 2016 09:57:51 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGRcB-0007kz-SP; Fri, 24 Jun 2016 09:57:47 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4015 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bGRc7-0005uH-WA; Fri, 24 Jun 2016 09:57:46 -0400 In-reply-to: <576D2895.4020600@gmail.com> (message from =?windows-1252?Q?C?= =?windows-1252?Q?l=E9ment?= Pit--Claudel on Fri, 24 Jun 2016 08:33:25 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204727 Archived-At: > Cc: acm@muc.de, schwab@suse.de, emacs-devel@gnu.org > From: Clément Pit--Claudel > Date: Fri, 24 Jun 2016 08:33:25 -0400 > > >> On 2016-06-23 15:11, Eli Zaretskii wrote: > >>> Instead of hypothesizing, I suggest to profile your code with > >>> profiler.el. If indeed redisplay is taking the time, you should > >>> see that in the profile. > >> > >> The profile doesn't show that, unfortunately; in fact, we spent a > >> significant amount of time trying to understand what was taking all > >> that time by looking at the profile, but nothing in there was > >> taking more than 30% of the time, and even optimizing away a > >> function that according to the profile took 28% of the time didn't > >> yield a measurable runtime difference. > >> > >> Commenting out the call to set-window-buffer (or predicating it on > >> the window not already displaying the buffer), on the other hand, > >> does yield a 95% performance gain. set-window-buffer does not > >> appear in the profile; redisplay_internal does appear, but it only > >> is credited with 30% of the execution time. > >> > >> I wonder what might explain these results... > > > > Any hope of seeing the profile, fully expanded? > > Absolutely. I've attached it. Looks like redisplay is indeed an important factor here. In addition, it looks like you have some subprocess from which you read input? What's the part of profile below about? - scomint-output-filter 173 26% - run-hook-with-args 173 26% - proof-shell-filter-wrapper 169 26% - byte-code 169 26% - proof-shell-filter 160 24% - proof-shell-filter-manage-output 137 21% - proof-shell-exec-loop 123 19% - mapc 95 14% - proof-shell-invoke-callback 93 14% - byte-code 93 14% - proof-done-advancing 93 14% Can you write some high-level overview of what the inner loop of your code does, including what is being redisplayed, and how input from subprocesses enters the picture? In addition, I suggest to run your benchmark several times, so as to eliminate the significant portion of time execute-extended-command and its subroutines, and the profiler itself, show in the profile? Also, load all the Lisp libraries as *.el files, so that the profile is more detailed.