nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] WIP: Use caching for regex


From: Benno Schulenberg
Subject: Re: [Nano-devel] WIP: Use caching for regex
Date: Wed, 31 Oct 2018 20:07:12 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

Op 30-10-18 om 22:32 schreef Devin Hussey:
> I was trying to figure out how to make RC file parsing faster. I
> initially thought it was strcmp hell, but I made a gperf and there was
> a whopping 0.010 second speedup, even with the nano syntax files
> included 8 times.

??  I don't get this.  What is a 'gperf'?  And what is a hundredth of
a second speedup?  Compared to what?

> So, I profiled nano, and I found the real bottleneck. Nano regcomps
> and regfrees aggressively (see: found_in_list). regcomp is a pretty
> expensive function, and that is the real reason that parsing is slow.
> 
> Nano has a lot of syntax rules that use the same regex, so I was
> thinking we should reuse the regexes whenever possible.

I think that is not the best way to optimize.  I've been thinking for
more than a year about another way to speed up the reading of nanorc
files, but it requires a rather invasive change, so I kept postponing
it.  Today I wrote up a "bug" report about it:

    https://savannah.gnu.org/bugs/?54928

In short: nano should read only the syntax, header and magic lines of
each syntax and then, after "selecting" the syntax for the current buffer,
it should fully read the relevant syntax file and compile all the regexes.
This will slow down switching between buffers that need different syntaxes,
but will reduce the regex compiling at startup by roughly 85 percent.

> Here is what I have now (it is a GitHub Gist, because I am not sure
> whether attaching stuff is a good idea):

Yes, attaching is a good idea.  Github is a big boo, and attaching it
means it gets archived and stays available.

Thanks for trying to speed up nano further.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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