emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs rendering comparisson between emacs23 and emacs26.3


From: Dmitry Gutov
Subject: Re: emacs rendering comparisson between emacs23 and emacs26.3
Date: Sun, 19 Apr 2020 21:12:57 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 19.04.2020 20:12, Alan Mackenzie wrote:

Yes, on average it's only 2x benefit, but then again, if the buffer
opens at its beginning first, the extra initialization will be spread
across user commands. Which should have some additional positive effect
on apparent responsiveness.

Will it?  A slightly faster appearance of the buffer at line 1 will be
offset by a slightly more sluggish response when doing M-x imenu foo.  And
"slightly" here means a fraction of a second on a modern machine,
presumably somewhat longer on an older one.

M-x file-file followed by M-x imenu should take ~as much as before. And if the user doesn't go for Imenu or scrolling to EOB right away, they get extra performance.

I don't know how slow it's for the average user, but there certainly are some with slow machines out there. Or people compiling without optimizations.

Inserting a C++ raw string opener does typically necessitate a full
scan (a search for a matching closer), but that would also be the case
using syntax-propertize.

Not really. It would just mark the opener as a string opener (maybe with
some extra text property), and that's that.

You don't know whether it's an unterminated raw string (the usual case)
until you've scanned for a potential closing delimiter.

Is C++ syntax so ambiguous? Can R"( mean something else?

This affects the
font locking.  (An unterminated opening delimiter gets
font-lock-warning-face, a terminated one doesn't.)

If everything after R"( is fontified as a string, it serves as a "warning" of sort as well.

This is the sort of feature which I'm not willing to sacrifice.

Is it worth a full buffer scan every time you write a new raw string literal?

Then font-lock would fontify the following text as string contents
(until the end of the window or a little bit farther). Then you type
the closer, it only has to scan a little far back (it'll call
syntax-ppss to find the string opener), the closer is propertized as
appropriate, and that's that. No full buffer scans at any step.

I recall that fontifying the rest of the buffer as text after a simple
string opener could be a sore topic for you, but raw strings should be
rare enough (aren't they?), or if they are not, fontification logic
could opt to do something different, while syntax-table properties will
be applied the "correct" way.

I'm not sure what you mean by "as text".

Sorry, I meant "as string".

I've no reason to think raw
strings are at all rare.  I've had several bug reports for them.  I'm not
sure what you mean by "fontification logic ... something different" - do
you mean in the raw string case?

I mean that if a raw string is unterminated, the default behavior should be to fontify the rest of the buffer as string. But then again, you could choose some different highliting in font-lock rules.

Or by "while s-t properties will be
applied in the "correct" way" - these properties are currently correctly
applied (modulo any remaining bugs).

In that case, you should always be able to find the beginning of the current string literal (raw or plain) using syntax-ppss.

Yes, I think before-change-functions should become empty. Or much emptier.

It can't become empty.  after-change-functions is fine for dealing with
insertions, but can't do much after a deletion.  Consider the case where
you're in a string and all you know is that 5 characters have been
deleted.  Those characters might have been )foo", so after checking the
beginning of the string starts off with R"bar(, you've then got to scan a
long way forward looking for )bar".  Effectively every deletion within a
string would involve scanning to the end of that string.

This is an example of extra complexity you have to retain to implement the above feature the way you do.

It's probably also an example of how before/after-change-functions essentially duplicate the knowledge of language syntax. I'm guessing here, but to make it work like that, you need to have multiple functions "understand" the raw string syntax.

Whereas with syntax-propertize-function, that knowledge is concentrated in one place (maybe two, if font-lock rules do something unusual). This way, the code is simplified.

Having actually gone through all the issues and implemented raw strings,
I can't agree with you there.  There are all sorts of subtleties which
necessitate intimate cooperation between the before-change-functions and
after-change-functions.  Such cooperation seems to be excluded by the
syntax-propertize mechanism.

It encourages a different approach. Again: there are examples of raw
strings support in other major modes.

Do any of them have the syntactical complexities of C++'s raw strings?

You tell me:

https://docs.ruby-lang.org/en/2.4.0/syntax/literals_rdoc.html#label-Percent+Strings
https://rosettacode.org/wiki/Here_document#Ruby
https://github.com/atom/language-ruby/issues/109#issue-98715165

Maybe, but with a slowdown.  More of these properties will get erased
than needed (with nested template forms), and they will all need to get
put back again.

We won't really know until we can measure the result.

What's the point in investing all the effort to make the change, when
there's not even a prediction of a speed up?

In principle, the speed-up will come from:

- Deferred execution (where several buffer changes can be handled together and not right away), - No parsing the buffer contents much farther than the current window, in most cases. Which can speed up the majority of user actions. The exceptions will remain slower, but that is often a good tradeoff.

And I'm not sure where the proof of the syntax-propertize mechanism being
helpful is.  Has anybody but its originator positively chosen to use it,
whilst being aware of the alternatives?

The alternatives being reinventing the relevant logic from zero in each major mode? And writing syntax caching logic each time?

To become usable for CC Mode, it would need to provide something on
before-change-functions to complement what's on a-c-f, and it would need
to provide some control to the major mode over which syntax-table
properties get erased.

Not something I can comment on.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]