From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#31888: 27.0.50; Segmentation fault in replace-buffer-contents Date: Mon, 25 Jun 2018 16:55:59 +0100 Message-ID: <87lgb2lv1s.fsf@gmail.com> References: <39638875-4e85-85dc-1cfa-3bfb7321e6b0@zoho.com> <83602bq8hl.fsf@gnu.org> <83bmc1vjn8.fsf@gnu.org> <877emnm97t.fsf@gmail.com> <83muvisyqv.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1529942165 12545 195.159.176.226 (25 Jun 2018 15:56:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 25 Jun 2018 15:56:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31888@debbugs.gnu.org, k.michal@zoho.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 25 17:56:01 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 1fXTqT-00039C-2K for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Jun 2018 17:56:01 +0200 Original-Received: from localhost ([::1]:47934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXTsa-0003e9-9k for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Jun 2018 11:58:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXTrW-00035J-IG for bug-gnu-emacs@gnu.org; Mon, 25 Jun 2018 11:57:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXTrS-0003T1-K8 for bug-gnu-emacs@gnu.org; Mon, 25 Jun 2018 11:57:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXTrS-0003SL-GO for bug-gnu-emacs@gnu.org; Mon, 25 Jun 2018 11:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fXTrS-0006Ww-5r for bug-gnu-emacs@gnu.org; Mon, 25 Jun 2018 11:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Jun 2018 15:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31888 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31888-submit@debbugs.gnu.org id=B31888.152994217625040 (code B ref 31888); Mon, 25 Jun 2018 15:57:02 +0000 Original-Received: (at 31888) by debbugs.gnu.org; 25 Jun 2018 15:56:16 +0000 Original-Received: from localhost ([127.0.0.1]:35108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fXTqh-0006Vo-Oh for submit@debbugs.gnu.org; Mon, 25 Jun 2018 11:56:15 -0400 Original-Received: from mail-wm0-f41.google.com ([74.125.82.41]:40059) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fXTqf-0006VX-SB for 31888@debbugs.gnu.org; Mon, 25 Jun 2018 11:56:14 -0400 Original-Received: by mail-wm0-f41.google.com with SMTP id z13-v6so4420747wma.5 for <31888@debbugs.gnu.org>; Mon, 25 Jun 2018 08:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=P84jfcg4mXyjZ1TTNFskwVUlpw/rCPcUQBx1tgzzjRo=; b=aiOzJI4PsBc82M6TBDbaW2Pvj1Av56JA5J5B5AT1S7zZJ24kAGS3QpatI0SAKrPRmM WcwjusvulFvYHl3h05ADr9GqfabniP1bCL9XSRtYL88Q0+6RmSvQaRzNcGUVWm/5KklS L3xsPIcTDCqkZR2MrJsymbxdtkB3PJl7ODZ7BAHvMGVWG8xMrnqdCQ8WNSp/entZXBPu LVi9IVVzAnUWATd3a23anYaGBRSSNkT4uIn0ScDU3cSwaDtPDIatY6LLacO/PNsERJkW u7UKjiTFqxfLird7gYAReC/h8BtCQAir8Qsz78w4aw2lsZEVjfrbIty3qtIv/1LFuXr8 IOrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=P84jfcg4mXyjZ1TTNFskwVUlpw/rCPcUQBx1tgzzjRo=; b=rXmD1AHQ1kuHyTxgxKT7aqIjkRA4h5V6XkZrP/WEFeeU5iK4CXPmVaFwb1vzbaZmN8 R/mlUE9nkYLJPNOEvehyF/E5F+1+pqYStBSpNKbSnm4pmFBtRKbgFUH2KTwYTN96kyiH rhlCJrY32uyBfjBy92FqyKIlmLldguq34KY0dMbJj/iYynFHpE90ia1+jlyKYkzpQdq1 I0JZ3FwGqgSma/OBleYhnjiC8/rbbOJ+YPYYykyHmCpGSau356V+JQIB5WQtkzmmWLjT ShT4XFspaOt4t6v6E3JWu+J2Xpccvk0KIIYmBA4dyhlXbL1xSml2aiO+TY3jwsSn0TO+ B46A== X-Gm-Message-State: APt69E0M9oe24Bow4uIJIcWWvTVXkcSmpaGfIZwOkKXnaQyL11j/NupW pRZ6yvutN5wGEzKyazJ1+J0= X-Google-Smtp-Source: ADUXVKLZTXWv/SMVbiafmWFbQuV7SNgap5wS52KKykHjxvpNjdZa1ERWg4APlD7oZqpmGbxvRPv0ng== X-Received: by 2002:a1c:f308:: with SMTP id q8-v6mr1450480wmq.6.1529942168053; Mon, 25 Jun 2018 08:56:08 -0700 (PDT) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id l67-v6sm12828894wmb.22.2018.06.25.08.56.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 08:56:07 -0700 (PDT) In-Reply-To: <83muvisyqv.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 25 Jun 2018 17:54:16 +0300") 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:147813 Archived-At: Eli Zaretskii writes: >> From: Jo=C3=A3o T=C3=A1vora >> Cc: eliz@gnu.org, k.michal@zoho.com >> Date: Mon, 25 Jun 2018 11:49:58 +0100 >>=20 >> I'm using this function in my Eglot package, but only because of its >> ability to preserve markers, not text properties. And only one marker in >> particular, the point marker. So I wonder if sth like a >> replace-buffer-contents-no-properties could be added: according to your >> analysis it could be significantly faster. > I doubt that, because keeping markers needs the same technique: > deletions interspersed with insertions, where both deletions and > insertions are as small as possible. Thanks for explaining. Without looking at the code, I would expect performance to vary in proportion to the number of things to preserve Thus, text properties, especially font-lock's, of which there are many more than markers, probably weigh more. > (You should only see the slowness if there are a lot of small > differences scattered all over the buffers. A few large differences > close together should let the function's optimized algorithm to do a > better job.) Thanks again. FWIW, here's why I need it: when asking the LSP server to reformat the buffer (mostly reindent + whitespace here and there), some servers answer with multiple small edits resulting in multiple replace-buffer-contents calls. For these cases, some speedup can probably be attained by only calling replace-buffer-contents when the affected region contains point. Unfortunately, other servers (Python's, afaik) reply with a complete slightly changed copy of a buffer, with short whitespace sequences added or removed more or less uniformely throughout buffer. These cases would probably fall into the conditions you describe. So maybe it could help if replace-buffer-contents accepted only a subset of buffer markers that need saving. Jo=C3=A3o