From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text properties when calling `back_comment'.
Date: Mon, 14 Mar 2016 17:29:40 +0000 [thread overview]
Message-ID: <20160314172940.GG1894@acm.fritz.box> (raw)
In-Reply-To: <dc6bb324-9d45-a3b1-d843-23d25dda8596@yandex.ru>
Hello, Dmitry.
On Mon, Mar 14, 2016 at 06:15:13PM +0200, Dmitry Gutov wrote:
> On 03/14/2016 02:23 PM, Alan Mackenzie wrote:
> >> Any performance numbers on using this approach in C/l mode?
> > [ By "this approach" I'm taking it you mean scanning forward from safe
> > positions.]
> No, using syntax-ppss's cache. Including the syntax-ppss-last variable.
CC Mode doesn't use syntax-ppss. It would be too much work to put it in,
particularly as that function's future is unclear.
> IIRC, Stefan posted a patch, which was like 10 lines long.
Sorry, patch for what? I've lost the context.
> Could you please try it already, so we can move on to discussing the
> actual performance problems of syntax-ppss, instead of theoretical ones?
It would be a lot of work. Perhaps you might like to undertake it.
> > It's two slow to use as a replacement for back_comment, in the sense I
> > would like to do - in place of scanning a comment backward character by
> > character, I want to use a cache (calculated by forward scanning) to
> > determine the beginning of a comment. Having to scan forward lots of
> > characters (as opposed to a few) is out of the question for this
> > application.
> The approach X is out of the question, because my approach Y is usually
> N times faster!
> Why is it out of the question? Can I say "premature optimization"?
You could, but it would sound a bit silly. back_comment currently works
by scanning backward a character at a time. Each character will take
about the same time to scan (give or take a factor of, perhaps, 2) as a
character being scanned forward in parse-partial-sexp.
Compare scanning backwards over a 100 character comment using the current
back_comment with scanning forwards up to 20,000 characters to get a
parse state on the comment's end position. CC Mode does a fair bit of
scanning backwards of comments sequentially. Even syntax-last-pos (or
whatever it's called) won't help much here.
But if you want to do the experiment, be my guest.
> >> So I have to wonder why the "get out of a comment" feature is used in
> >> C/l mode so much that it becomes a bottleneck, and you get significant
> >> improvement in performance by dropping the caching logic to C. That is,
> >> of course, not a nice thing to ask considering the overall complexity of
> >> CC Mode, but still.
> >> I don't see anything comparable to 10 second waiting described in
> >> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22884, when doing a
> >> comparable operation in a 5000-line Ruby file.
> > Here's a quick summary of how that happened: on L1661 of config.h, C
> > Mode had to scan back to the beginning of a statement. That involved
> > going back over ~1600 lines of comments and preprocessor constructs.
> I went back to the revision a589e9a and rebuilt Emacs. I see the problem
> described in 22884. However, the line 1661 already is a beginning of a
> statement. It contains:
> #define _DARWIN_USE_64_BIT_INODE 1
> Are we talking about the same file?
Possibly. config.h is different between different runs of ./configure.
In the file Paul was complaining about, there was a comment opener at the
start of the line. I think it was actually the line you've cited, but
commented out.
> > When it got to the critical comment and tried to go back over it,
> > (forward-comment -1) said nil, because of that paren in column 0. That
> > paren in column 0, although in a comment, was deemed to be the start of
> > a defun. C Mode was then trying to parse "code" over a region with a
> > 1600 line gap in the middle.
> > Hence the 10 second delay in seeing the
> > character echoed. Paul has purged our code of parens in column 0. But
> > it would be nice not to have the restriction.
> (parse-partial-sexp 1 (point)) on line 1661 takes ~0.002s here.
> (parse-partial-sexp 1 (point-max)) takes just a little above that.
> How do these timings translate into whole seconds of waiting after
> pressing '/'?
They don't. It was CC Mode's indentation engine's scanning, not the raw
parse-partial-sexp scanning.
> > My point was that it is so simple that it _could_ be written in C, and
> > that without any great difficulties.
> "It was so simple that I made it more complex"? I mentioned C as a
> drawback, and it is.
Lots of Emacs is written in C. In this particular case, it is a good
idea to avoid the possible complications and pitfalls of calling lisp
from C when it is not necessary, particularly given the lack of any
involved code which would make lisp the preferred language.
> > Parts of it can only be written in
> > C (the bits that ensure the cache is marked stale when certain
> > sytax-table text properties are set/cleared when
> > `inhibit-modification-hooks' is bound to non-nil).
> These would have to be carefully considered, but if they make sense,
> they would have to be ported to syntax-ppss too somehow.
That wouldn't be a bad idea, once the future of that function becomes
clear.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2016-03-14 17:29 UTC|newest]
Thread overview: 130+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20160308132530.861.91488@vcs.savannah.gnu.org>
[not found] ` <E1adHdj-0000FI-0W@vcs.savannah.gnu.org>
2016-03-08 14:19 ` [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text properties when calling `back_comment' Stefan Monnier
2016-03-08 18:30 ` Alan Mackenzie
2016-03-08 18:42 ` Stefan Monnier
2016-03-08 20:07 ` Alan Mackenzie
2016-03-08 21:22 ` Dmitry Gutov
2016-03-08 21:43 ` Alan Mackenzie
2016-03-09 0:17 ` Stefan Monnier
2016-03-09 1:54 ` Stefan Monnier
2016-03-09 10:49 ` Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.] Alan Mackenzie
2016-03-09 13:11 ` Stefan Monnier
2016-03-09 14:19 ` Alan Mackenzie
2016-03-09 19:16 ` Stefan Monnier
2016-03-09 19:22 ` Clément Pit--Claudel
2016-03-09 19:37 ` Alan Mackenzie
2016-03-09 21:40 ` Stefan Monnier
2016-03-10 13:01 ` Alan Mackenzie
2016-03-10 14:52 ` Stefan Monnier
2016-03-10 15:29 ` Alan Mackenzie
2016-03-10 16:45 ` Stefan Monnier
2016-03-10 17:25 ` Alan Mackenzie
2016-03-10 17:34 ` Stefan Monnier
2016-03-10 19:08 ` Alan Mackenzie
2016-03-10 23:10 ` Stefan Monnier
2016-03-11 12:50 ` Stefan Monnier
2016-03-11 20:48 ` Alan Mackenzie
2016-03-11 22:35 ` Stefan Monnier
2016-03-11 23:08 ` Alan Mackenzie
2016-03-11 23:09 ` Clément Pit--Claudel
2016-03-11 23:31 ` Stefan Monnier
2016-03-10 23:31 ` John Wiegley
2016-03-11 2:08 ` Clément Pit--Claudel
2016-03-11 3:08 ` Stefan Monnier
2016-03-11 7:27 ` Andreas Röhler
2016-03-11 12:08 ` Alan Mackenzie
2016-03-11 12:30 ` Dmitry Gutov
2016-03-11 13:04 ` Alan Mackenzie
2016-03-11 20:21 ` Dmitry Gutov
2016-03-12 20:19 ` Andreas Röhler
2016-03-12 20:38 ` Dmitry Gutov
2016-03-12 20:45 ` Alan Mackenzie
2016-03-13 14:56 ` Andreas Röhler
2016-03-10 13:41 ` Stefan Monnier
2016-03-09 17:06 ` How do you check if the current point is in a comment or a string? (Was Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.]) Clément Pit--Claudel
2016-03-09 17:24 ` Kaushal Modi
2016-03-09 17:56 ` Clément Pit--Claudel
2016-03-09 19:19 ` Kaushal Modi
2016-03-09 19:34 ` Clément Pit--Claudel
2016-03-10 14:28 ` Stefan Monnier
2016-03-10 15:03 ` Clément Pit--Claudel
2016-03-10 15:20 ` Stefan Monnier
2016-03-10 17:21 ` Clément Pit--Claudel
2016-03-12 20:45 ` Andreas Röhler
2016-03-12 20:53 ` Clément Pit--Claudel
2016-03-09 16:37 ` [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text properties when calling `back_comment' Richard Stallman
2016-03-09 17:06 ` Dmitry Gutov
2016-03-10 21:20 ` Richard Stallman
2016-03-11 0:26 ` Dmitry Gutov
2016-03-11 12:22 ` Alan Mackenzie
2016-03-11 12:52 ` Stefan Monnier
2016-03-11 16:20 ` Drew Adams
2016-03-09 17:48 ` Alan Mackenzie
2016-03-09 19:58 ` martin rudalics
2016-03-09 20:36 ` Eli Zaretskii
2016-03-09 20:53 ` John Wiegley
2016-03-13 9:30 ` Daniel Colascione
2016-03-13 15:28 ` Stefan Monnier
2016-03-13 16:24 ` Eli Zaretskii
2016-03-13 16:27 ` Daniel Colascione
2016-03-13 17:19 ` Eli Zaretskii
2016-03-14 1:13 ` Stefan Monnier
2016-03-14 16:10 ` Eli Zaretskii
2016-03-11 18:27 ` Alan Mackenzie
2016-03-12 17:08 ` Alan Mackenzie
2016-03-12 18:10 ` martin rudalics
2016-03-12 18:22 ` Paul Eggert
2016-03-12 18:46 ` martin rudalics
2016-03-12 19:36 ` Alan Mackenzie
2016-03-13 9:26 ` martin rudalics
2016-03-13 11:52 ` Alan Mackenzie
2016-03-13 12:08 ` martin rudalics
2016-03-13 12:49 ` Alan Mackenzie
2016-03-13 13:32 ` martin rudalics
2016-03-13 17:59 ` Eli Zaretskii
2016-03-13 20:09 ` martin rudalics
2016-03-14 1:15 ` Paul Eggert
2016-03-14 7:42 ` martin rudalics
2016-03-14 11:22 ` Alan Mackenzie
2016-03-14 19:41 ` martin rudalics
2016-03-14 20:58 ` Alan Mackenzie
2016-03-14 16:15 ` Eli Zaretskii
2016-03-14 19:41 ` martin rudalics
2016-03-14 17:00 ` Paul Eggert
2016-03-14 19:41 ` martin rudalics
2016-03-14 16:09 ` Eli Zaretskii
2016-03-13 18:00 ` Eli Zaretskii
2016-03-13 18:41 ` Alan Mackenzie
2016-03-12 20:56 ` Dmitry Gutov
2016-03-12 21:29 ` Clément Pit--Claudel
2016-03-12 21:59 ` Dmitry Gutov
2016-03-12 21:58 ` Alan Mackenzie
2016-03-12 22:16 ` Dmitry Gutov
2016-03-13 17:59 ` Alan Mackenzie
2016-03-13 22:49 ` Stefan Monnier
2016-03-14 12:51 ` Alan Mackenzie
2016-03-15 3:14 ` Stefan Monnier
2016-03-14 1:13 ` Dmitry Gutov
2016-03-14 1:30 ` Stefan Monnier
2016-03-14 1:45 ` Dmitry Gutov
2016-03-14 2:18 ` Stefan Monnier
2016-03-14 12:23 ` Alan Mackenzie
2016-03-14 16:15 ` Dmitry Gutov
2016-03-14 17:29 ` Alan Mackenzie [this message]
2016-03-14 17:52 ` Dmitry Gutov
2016-03-14 18:46 ` Alan Mackenzie
2016-03-14 19:33 ` Dmitry Gutov
2016-03-14 21:20 ` Alan Mackenzie
2016-03-15 3:10 ` Stefan Monnier
2016-03-17 0:47 ` Dmitry Gutov
2016-03-17 18:47 ` Alan Mackenzie
2016-03-18 1:24 ` Dmitry Gutov
2016-03-10 21:20 ` Richard Stallman
2016-03-10 22:24 ` Alan Mackenzie
2016-03-12 1:53 ` Richard Stallman
2016-03-12 3:28 ` Stefan Monnier
2016-03-12 19:28 ` Richard Stallman
2016-03-09 17:51 ` Clément Pit--Claudel
2016-03-10 21:20 ` Richard Stallman
2016-03-10 21:38 ` Clément Pit--Claudel
2016-03-12 1:53 ` Richard Stallman
2016-03-10 7:14 ` Andreas Röhler
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160314172940.GG1894@acm.fritz.box \
--to=acm@muc.de \
--cc=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.