unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>, Paul Eggert <eggert@cs.ucla.edu>
Cc: monnier@IRO.UMontreal.CA, emacs-devel@gnu.org
Subject: Re: [RFC]: replace-region-contents
Date: Wed, 06 Feb 2019 19:07:38 +0100	[thread overview]
Message-ID: <87lg2saiz9.fsf@gnu.org> (raw)
In-Reply-To: <83mun8styg.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Feb 2019 19:33:11 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

Hi Paul,

the context is `replace-buffer-contents' or rather compareseq in
lib/diffseq.h being too slow when being called where the source buffer
contains a huge, one-line JSON string and the replacing buffer contains
the formatted version.  I.e., the buffer contents are almost equal
modulo gazillion of whitespace/linebreak changes.

>> Maybe that could signal if more than some maximum number of
>> differences have already been found, and in that case
>> `replace-buffer-contents' would fallback to a plain delete and
>> insert?
>
> There's the too_expensive member that we currently set to a very large
> value; maybe we should set it lower? or provide control on it from
> Lisp?

I've just tried playing with that.  We currently set it too one million,
and then the `replace-buffer-contents' call won't finish within 30
minutes on my computer.  As a base-line, the current `json-pretty-print'
without `replace-buffer-contents' takes about 2 seconds.

With a too_expensive value of 1000, it takes about 14 seconds with my
huge, worst-case JSON file.  With a value of 100 it takes about 3
seconds.  With a value of 10, it segfaults.  I guess there's some
minimum boundary.

However, I'm not really sure what the implications are.  The comments
say it produces suboptimal output.  But what does that mean here?  In
the end, the formatted JSON is copied over from the replacing buffer
as-is, and that's the most important thing.

> Also, there's the EARLY_ABORT macro that can be defined to cause an
> early return when the job is too hard.  Maybe you could try defining
> it to something appropriate?

And fallback to plain delete & insert when it returned early?  Not sure
if that's better.  Right now, a (much) lower value of too_expensive
seems like a good option.

Bye,
Tassilo



  reply	other threads:[~2019-02-06 18:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 21:20 [RFC]: replace-region-contents Tassilo Horn
2019-02-02  9:33 ` Marcin Borkowski
2019-02-02 13:57   ` Tassilo Horn
2019-02-02 15:42 ` Stefan Monnier
2019-02-04  5:23   ` Tassilo Horn
2019-02-05  2:56     ` Stefan Monnier
2019-02-05  5:57       ` Tassilo Horn
2019-02-05 13:21         ` Tassilo Horn
2019-02-05 16:36           ` Eli Zaretskii
2019-02-05 17:19             ` Tassilo Horn
2019-02-06 16:00               ` Eli Zaretskii
2019-02-06 17:02                 ` Tassilo Horn
2019-02-06 17:33                   ` Eli Zaretskii
2019-02-06 18:07                     ` Tassilo Horn [this message]
2019-02-08 16:23                       ` Tassilo Horn
2019-02-08 16:28                         ` Stefan Monnier
2019-02-08 17:17                           ` Tassilo Horn
2019-02-08 21:37                             ` Eli Zaretskii
2019-02-08 21:53                               ` Stefan Monnier
2019-02-08 21:27                         ` Eli Zaretskii
2019-02-08 22:03                           ` Tassilo Horn
2019-02-08 22:19                             ` Eli Zaretskii
2019-02-09  0:00                           ` Tassilo Horn
2019-02-09  8:26                             ` Eli Zaretskii
2019-02-09  8:52                               ` Tassilo Horn
2019-02-05 13:43         ` Stefan Monnier
2019-02-06  8:07           ` Tassilo Horn
2019-02-06  9:55             ` Marcin Borkowski
2019-02-06 11:10               ` Tassilo Horn
2019-02-06 14:09             ` Stefan Monnier
2019-02-05 16:11         ` Eli Zaretskii
2019-02-02 16:17 ` Stefan Monnier
2019-02-03 15:59   ` Eli Zaretskii
2019-02-03 17:05     ` Stefan Monnier
2019-02-03 17:18       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lg2saiz9.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).