zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match)
Date: Sun, 14 Feb 2016 14:34:41 +0000	[thread overview]
Message-ID: <20160214143441.GB11737@tarsus.local2> (raw)
In-Reply-To: <CAKc7PVDDUDBdu0y-KmYXqwzqY8rPeeBQ9Fhi1RFZ5aXO6Wmt5g@mail.gmail.com>

Sebastian Gniazdowski wrote on Thu, Feb 11, 2016 at 17:11:57 +0100:
> On 11 February 2016 at 11:43, Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> > That said, zsyh could be somewhat optimized if the ":howmany" syntax
> > would be utilized.
> 
> Could came up with this:
> ./parse.zsh "zplugin.zsh" > out1.txt 128,78s user 8,61s system 99% cpu
> 2:17,85 total
> ./parse.zsh "zplugin.zsh" > out2.txt 74,34s user 8,38s system 99% cpu
> 1:23,12 total
> 
> https://github.com/zsh-users/zsh-syntax-highlighting/pull/272
> 

Thanks!  Merged, will be in 0.5.0.

However, I think avoiding the strlen() isn't the main benefit here:
I suspect the expression $buf[start_pos+1,-1], which is evaluated in
every iteration of the loop, might have triggered an O(N²) allocations
pattern, even before considering the implicit strlen for the -1 (or the
explicit strlen in the "else" branch).

The next step might be to see whether the two remaining instances of
that expression (one in the 'if' branch and one in the 'else' branch)
can also be simplified: for example, by precomputing the indices of all
newlines, semicolons, and starts-of-words (places where the regexp /\</
matches) in $buf.

Many thanks for your investigation!  I'd also like to thank Bart for his
help (some of which was offlist).

Daniel


  parent reply	other threads:[~2016-02-14 14:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12  7:32 "drop-in replacement" and transpose-words-match Bart Schaefer
2016-01-18  2:25 ` Daniel Shahaf
2016-01-18 16:29   ` Bart Schaefer
2016-01-18 17:04 ` Sebastian Gniazdowski
2016-01-19  6:31   ` Bart Schaefer
2016-01-19  8:28     ` Sebastian Gniazdowski
2016-01-20  3:56       ` Bart Schaefer
2016-01-23 23:53         ` Daniel Shahaf
2016-01-24  6:20           ` Slow highlighting (Re: "drop-in replacement" and transpose-words-match) Bart Schaefer
2016-01-26 22:50             ` Daniel Shahaf
2016-01-27  4:31               ` Bart Schaefer
2016-01-27  5:10                 ` Mikael Magnusson
2016-01-29  9:18                 ` Daniel Shahaf
2016-02-10 16:32             ` Sebastian Gniazdowski
2016-02-10 18:18               ` Bart Schaefer
2016-02-10 18:37                 ` Sebastian Gniazdowski
2016-02-11 10:43                 ` Sebastian Gniazdowski
2016-02-11 12:07                   ` Sebastian Gniazdowski
2016-02-14 14:34                     ` Daniel Shahaf
2016-02-11 16:11                   ` Sebastian Gniazdowski
2016-02-12  7:34                     ` Sebastian Gniazdowski
2016-02-12 10:05                     ` Bart Schaefer
2016-02-14 14:34                     ` Daniel Shahaf [this message]
2016-02-12  9:41                   ` Bart Schaefer
2016-05-06 13:15                     ` Sebastian Gniazdowski
2016-02-14 14:34                   ` Avoiding github link bitrot " Daniel Shahaf
2016-01-20  7:47       ` "drop-in replacement" and transpose-words-match Daniel Shahaf

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=20160214143441.GB11737@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=sgniazdowski@gmail.com \
    --cc=zsh-workers@zsh.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 public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).