From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#31888: 27.0.50; Segmentation fault in replace-buffer-contents Date: Sat, 23 Jun 2018 14:15:23 +0300 Message-ID: <83bmc1vjn8.fsf@gnu.org> References: <39638875-4e85-85dc-1cfa-3bfb7321e6b0@zoho.com> <83602bq8hl.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1529752457 19669 195.159.176.226 (23 Jun 2018 11:14:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 23 Jun 2018 11:14:17 +0000 (UTC) Cc: 31888-done@debbugs.gnu.org To: k.michal@zoho.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 23 13:14:13 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWgUY-0004uG-PA for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Jun 2018 13:14:06 +0200 Original-Received: from localhost ([::1]:37996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWgWf-0007Wv-R8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Jun 2018 07:16:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWgWV-0007Wk-9t for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 07:16:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWgWS-00050r-4V for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 07:16:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWgWS-00050i-0n for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 07:16:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fWgWR-0006hT-OZ for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 07:16:03 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Jun 2018 11:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 31888 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 31888@debbugs.gnu.org, eliz@gnu.org, k.michal@zoho.com Original-Received: via spool by 31888-done@debbugs.gnu.org id=D31888.152975252325679 (code D ref 31888); Sat, 23 Jun 2018 11:16:02 +0000 Original-Received: (at 31888-done) by debbugs.gnu.org; 23 Jun 2018 11:15:23 +0000 Original-Received: from localhost ([127.0.0.1]:60846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWgVm-0006g7-OU for submit@debbugs.gnu.org; Sat, 23 Jun 2018 07:15:22 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56535) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWgVl-0006fq-I8 for 31888-done@debbugs.gnu.org; Sat, 23 Jun 2018 07:15:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWgVd-0004p9-77 for 31888-done@debbugs.gnu.org; Sat, 23 Jun 2018 07:15:16 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWgVd-0004p5-2x; Sat, 23 Jun 2018 07:15:13 -0400 Original-Received: from [176.228.60.248] (port=2820 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fWgVc-0002Eh-6f; Sat, 23 Jun 2018 07:15:12 -0400 In-reply-to: <83602bq8hl.fsf@gnu.org> (message from Eli Zaretskii on Fri, 22 Jun 2018 16:03:02 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:147763 Archived-At: > Date: Fri, 22 Jun 2018 16:03:02 +0300 > From: Eli Zaretskii > Cc: 31888@debbugs.gnu.org > > The command is still too slow (takes about 2.5 min for the above use > case in my unoptimized build, about 30 sec of which is spent in > compareseq). I will try to look into speeding it up. I could find only a minor speedup (about 10%), by slightly changing buffer_chars_equal per suggestion in another bug report. In this particular case, replacing the contents of dispnew.c with that of contents.c takes 2018 deletions and 2781 insertions, each one of these operations takes about 20 msec in the unoptimized build where I timed them; the call to compareseq takes another 26 sec (expect the times to be lower by a factor of 3 in an optimized build). My conclusion from various attempts to speed up the code was that most of this time is taken by making small changes to buffer text, which involves moving the gap, which in turn requires shuffling of buffer text to and fro. I don't see how can we speed that up if we stay with the current idea of the function, and want to preserve text properties and overlays as much as possible. So I ended up inserting a few calls to maybe_quit into the inner loops of the function, to allow users bail out of lengthy execution, and warning about the potential slowness in the doc string. I'm closing this bug; if someone has ideas for how to speed up the function significantly, please reopen, or file a new bug.