[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).

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_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/syntax/yaml.vim b/runtime/syntax/yaml.vim
--- a/runtime/syntax/yaml.vim
+++ b/runtime/syntax/yaml.vim
@@ -11,11 +11,11 @@ endif
 let s:cpo_save = &cpo
 set cpo&vim
 
-let s:ns_char = '\%(\%([\n\r\uFEFF \t]\)\@!\p\)'
+let s:ns_char = '\%(\%([\n\r\uFEFF \t]\)\@100!\p\)'
 let s:ns_word_char = '\%(\w\|-\)'
 let s:ns_uri_char  = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$,.!~*''()\[\]]\)'
 let s:ns_tag_char  = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$.~*''()]\)'
-let s:c_ns_anchor_char = '\%(\%([\n\r\uFEFF \t,\[\]{}]\)\@!\p\)'
+let s:c_ns_anchor_char = '\%(\%([\n\r\uFEFF \t,\[\]{}]\)\@100!\p\)'
 let s:c_indicator      = '[\-?:,\[\]{}#&*!|>''"%@`]'
 let s:c_flow_indicator = '[,\[\]{}]'
 
@@ -44,16 +44,18 @@ let s:ns_tag_prefix = s:ns_local_tag_pre
             \    '\|'.s:ns_global_tag_prefix
 
 let s:ns_plain_safe_out = s:ns_char
-let s:ns_plain_safe_in  = '\%('.s:c_flow_indicator.'\@!'.s:ns_char.'\)'
+let s:ns_plain_safe_in  = '\%('.s:c_flow_indicator.'\@100!'.s:ns_char.'\)'
 
-let s:ns_plain_first_in  = '\%('.s:c_indicator.'\@!'.s:ns_char.'\|[?:\-]\%('.s:ns_plain_safe_in.'\)\@=\)'
-let s:ns_plain_first_out = '\%('.s:c_indicator.'\@!'.s:ns_char.'\|[?:\-]\%('.s:ns_plain_safe_out.'\)\@=\)'
+let s:ns_plain_first_in  = '\%('.s:c_indicator.'\@100!'.s:ns_char.'\|[?:\-]\%('.s:ns_plain_safe_in.'\)\@100=\)'
+let s:ns_plain_first_out = '\%('.s:c_indicator.'\@100!'.s:ns_char.'\|[?:\-]\%('.s:ns_plain_safe_out.'\)\@100=\)'
 
-let s:ns_plain_char_in  = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_in.'\|[:#]\@!'.s:ns_plain_safe_in.'\)'
-let s:ns_plain_char_out = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_out.'\|[:#]\@!'.s:ns_plain_safe_out.'\)'
+let s:ns_plain_char_in  = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_in.'\|[:#]\@100!'.s:ns_plain_safe_in.'\)'
+let s:ns_plain_char_out = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_out.'\|[:#]\@100!'.s:ns_plain_safe_out.'\)'
 
-let s:ns_plain_out = s:ns_plain_first_out . s:ns_plain_char_out.'*'
-let s:ns_plain_in  = s:ns_plain_first_in  . s:ns_plain_char_in.'*'
+" Use old RE engine, to speed up syntax highlighting some, the new engine has
+" problems with look-around assertions
+let s:ns_plain_out = '\%#=1'. s:ns_plain_first_out . s:ns_plain_char_out.'*'
+let s:ns_plain_in  = '\%#=1'. s:ns_plain_first_in  . s:ns_plain_char_in.'*'
 
 
 syn keyword yamlTodo            contained TODO FIXME XXX NOTE
@@ -76,7 +78,7 @@ syn match yamlYAMLDirective '%YAML\s\+' 
 syn match yamlYAMLVersion   '\d\+\.\d\+' contained nextgroup=yamlComment
 
 execute 'syn match yamlReservedDirective contained nextgroup=yamlComment '.
-            \string('%\%(\%(TAG\|YAML\)\s\)\@!'.s:ns_directive_name)
+            \string('%\%(\%(TAG\|YAML\)\s\)\@100!'.s:ns_directive_name)
 
 syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start='"' skip='\\"' end='"'
             \ contains=yamlEscape
@@ -123,10 +125,10 @@ syn keyword yamlConstant true True TRUE 
 syn keyword yamlConstant null Null NULL
 syn match   yamlConstant '\<\~\>'
 
-syn match   yamlTimestamp /\%([\[\]{}, \t]\@!\p\)\@<!\%(\d\{4}-\d\d\=-\d\d\=\%(\%([Tt]\|\s\+\)\%(\d\d\=\):\%(\d\d\):\%(\d\d\)\%(\.\%(\d*\)\)\=\%(\s*\%(Z\|[+-]\d\d\=\%(:\d\d\)\=\)\)\=\)\=\)\%([\[\]{}, \t]\@!\p\)\@!/
+syn match   yamlTimestamp /\%#=1\%([\[\]{}, \t]\@100!\p\)\@100<!\%(\d\{4}-\d\d\=-\d\d\=\%(\%([Tt]\|\s\+\)\%(\d\d\=\):\%(\d\d\):\%(\d\d\)\%(\.\%(\d*\)\)\=\%(\s*\%(Z\|[+-]\d\d\=\%(:\d\d\)\=\)\)\=\)\=\)\%([\[\]{}, \t]\@100!\p\)\@100!/
 
-syn match   yamlInteger /\%([\[\]{}, \t]\@!\p\)\@<!\%([+-]\=\%(0\%(b[0-1_]\+\|[0-7_]\+\|x[0-9a-fA-F_]\+\)\=\|\%([1-9][0-9_]*\%(:[0-5]\=\d\)\+\)\)\|[1-9][0-9_]*\)\%([\[\]{}, \t]\@!\p\)\@!/
-syn match   yamlFloat   /\%([\[\]{}, \t]\@!\p\)\@<!\%([+-]\=\%(\%(\d[0-9_]*\)\.[0-9_]*\%([eE][+-]\d\+\)\=\|\.[0-9_]\+\%([eE][-+][0-9]\+\)\=\|\d[0-9_]*\%(:[0-5]\=\d\)\+\.[0-9_]*\|\.\%(inf\|Inf\|INF\)\)\|\%(\.\%(nan\|NaN\|NAN\)\)\)\%([\[\]{}, \t]\@!\p\)\@!/
+syn match   yamlInteger /\%#=1\%([\[\]{}, \t]\@100!\p\)\@100<!\%([+-]\=\%(0\%(b[0-1_]\+\|[0-7_]\+\|x[0-9a-fA-F_]\+\)\=\|\%([1-9][0-9_]*\%(:[0-5]\=\d\)\+\)\)\|[1-9][0-9_]*\)\%([\[\]{}, \t]\@100!\p\)\@100!/
+syn match   yamlFloat   /\%#=1\%([\[\]{}, \t]\@100!\p\)\@100<!\%([+-]\=\%(\%(\d[0-9_]*\)\.[0-9_]*\%([eE][+-]\d\+\)\=\|\.[0-9_]\+\%([eE][-+][0-9]\+\)\=\|\d[0-9_]*\%(:[0-5]\=\d\)\+\.[0-9_]*\|\.\%(inf\|Inf\|INF\)\)\|\%(\.\%(nan\|NaN\|NAN\)\)\)\%([\[\]{}, \t]\@100!\p\)\@100!/
 
 execute 'syn match yamlNodeTag '.string(s:c_ns_tag_property)
 execute 'syn match yamlAnchor  '.string(s:c_ns_anchor_property)

Raspunde prin e-mail lui