Thursday, March 27, 2014

Re: Extremely slow when using relativenumber & syntax highlighting


On Mar 27, 2014 7:56 PM, "Christian Brabandt" <cblists@256bit.org> wrote:
>
> [copying Zyx, as he is the maintainer of the syntax script]
>
> Am 2014-03-27 00:05, schrieb Dominique Pellé:
>>
>> I can reproduce the slowness using the yaml file copied
>> from http://yaml.org
>
> [...]
>
>>
>> If I use ":syntime on" and ":syntime report", I see this:
>>
>> With relativenumber:
>>
>>   TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN
>>   3.706423   7752   7395    0.002521    0.000478  yamlPlainScalar
>> \%([\-?:,\[\]{}#&*!|>'"%@`]\@!\%(\%([\n\r\uFEFF
>> \t]\)\@!\p\)\|[?:\-]\%(\%(\%([\n\r\uFEFF \t]\)\@!\p\)\)\@=
>>   1.105733   4029   2040    0.000742    0.000274  yamlFloat
>> \%([\[\]{},
>> \t]\@!\p\)\@<!\%([+-]\=\%(\%(\d[0-9_]*\)\.[0-9_]*\%([eE][+-]\d\+\)\=\|\.[0-9_]\+\%([eE][-+][0-
>>   0.711836   1224   0       0.001174    0.000582  yamlBlockMappingKey
>> \%#=1\s*\zs\%([\-?:,\[\]{}#&*!|>'"%@`]\@!\%(\%([\n\r\uFEFF
>> \t]\)\@!\p\)\|[?:\-]\%(\%(\%([\n\r\uFEFF \t]\)\
>>
>>   0.481088   2703   153     0.000815    0.000178  yamlInteger
>> \%([\[\]{},
>> \t]\@!\p\)\@<!\%([+-]\=\%(0\%(b[0-1_]\+\|[0-7_]\+\|x[0-9a-fA-F_]\+\)\=\|\%([1-9][0-9_]*\%(:[0-
>>   0.044233   2601   0       0.000042    0.000017  yamlTimestamp
>> \%([\[\]{},
>> \t]\@!\p\)\@<!\%(\d\{4}-\d\d\=-\d\d\=\%(\%([Tt]\|\s\+\)\%(\d\d\=\):\%(\d\d\):\%(\d\d\)\%(\.\%(
>>   0.038902   2652   408     0.000056    0.000015  yamlBlockMappingKey
>> \%#=1^\s*\zs\%([\-?:,\[\]{}#&*!|>'"%@`]\@!\%(\%([\n\r\uFEFF
>> \t]\)\@!\p\)\|[?:\-]\%(\%(\%([\n\r\uFEFF \t]\)
>
>
> Those patterns are crazy. Here is a patch, that deviates the performance issue slightly
> (mainly by making sure, the old 're' engine is used in place of those high performance syntax
> items and by limiting the look-around assertion). This fixes the performance penalties
> even more but might make syntax highlighting more inaccurate (although I used a conservative
> limit of 100 bytes).

If I understand these limits correctly it can be limited to an exact amount of bytes: AFAIR I was using only fixed-width lookarounds (making these limits be possible to be deduced by re engine). At least this patch touches only fixed-width lookarounds. Though I may understand these limits not correctly.

>
> Also, I noticed, the syntax script is missing some :syn sync rules. I am not sure, what the default
> is, but some clever syn rules could also improve syntax performance slightly.
>
> Best,
> Christian

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: