Loading ...
Sorry, an error occurred while loading the content.

Re: Very slow yaml syntax highlighting (7.3.1106)

Expand Messages
  • Bram Moolenaar
    ... I found a way to make these two faster. ... This pattern is just crazy... And it matches nearly everywhere. -- hundred-and-one symptoms of being an
    Message 1 of 12 , Jun 14, 2013
    • 0 Attachment
      lcd047 wrote:

      > On 14 June 2013, Ben Fritz <fritzophrenic@...> wrote:
      > > On Friday, June 14, 2013 7:58:48 AM UTC-5, Christian Wellenbrock
      > > wrote:
      > > > I attached a yaml file as example. Please open it with vim to test
      > > > the highlighting speed. Scolling and searching is very slow. Tested
      > > > on vim 7.3.1106
      > >
      > > 1106 is very old news for the new regex engine. At that point Bram was
      > > still implementing basic functionality. All the speed improvements
      > > came later. Please try again with 1189 or later.
      >
      > With 7.3.1188 highlighting is still >10 times slower with the re=0
      > compared to re=1. FWIW.
      >
      > /lcd
      >
      >
      > re = 0:
      > =======
      >
      > TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
      > 0.131778 463 0 0.000444 0.000285 yamlFloat \%([\[\]{}, \t]\@!\p\)\@<!\%([+-]\=\%(\%(\d[0-9_]*\)\.[0-9
      > 0.128999 463 0 0.000414 0.000279 yamlInteger \%([\[\]{}, \t]\@!\p\)\@<!\%([+-]\=\%(0\%(b[0-1_]\+\|[0-7_

      I found a way to make these two faster.

      > 0.081751 746 716 0.000151 0.000110 yamlPlainScalar \%([\-?:,\[\]{}#&*!|>'"%@`]\@!\%(\%([\n\r\uFEFF \t]\)\@!\p

      This pattern is just crazy... And it matches nearly everywhere.


      --
      hundred-and-one symptoms of being an internet addict:
      205. You're constantly yelling at your spouse, family, roommate, whatever,
      for using the phone for stupid things...like talking.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • tomas.mozes@...
      ... Still valid for 7.4.488. This seems to work much better: https://github.com/stephpy/vim-yaml/blob/master/after/syntax/yaml.vim -- -- You received this
      Message 2 of 12 , Nov 7, 2014
      • 0 Attachment
        On Friday, June 14, 2013 2:58:48 PM UTC+2, Christian Wellenbrock wrote:
        > I attached a yaml file as example. Please open it with vim to test the highlighting speed. Scolling and searching is very slow. Tested on vim 7.3.1106

        Still valid for 7.4.488.

        This seems to work much better:
        https://github.com/stephpy/vim-yaml/blob/master/after/syntax/yaml.vim

        --
        --
        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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Bram Moolenaar
        ... Have you tried with 7.4.497 or later? It is supposed to fix slowness with some patterns. -- Yesterday is history. Tomorrow is a mystery. Today is a gift.
        Message 3 of 12 , Nov 7, 2014
        • 0 Attachment
          Tomas Mozes wrote:

          > On Friday, June 14, 2013 2:58:48 PM UTC+2, Christian Wellenbrock wrote:
          > > I attached a yaml file as example. Please open it with vim to test the highlighting speed. Scolling and searching is very slow. Tested on vim 7.3.1106
          >
          > Still valid for 7.4.488.
          >
          > This seems to work much better:
          > https://github.com/stephpy/vim-yaml/blob/master/after/syntax/yaml.vim

          Have you tried with 7.4.497 or later? It is supposed to fix slowness
          with some patterns.

          --
          Yesterday is history.
          Tomorrow is a mystery.
          Today is a gift.
          That's why it is called 'present'.

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          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 vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Tomas Mozes
          Just tried 7.4.507, still the same. ... -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are
          Message 4 of 12 , Nov 10, 2014
          • 0 Attachment
            Just tried 7.4.507, still the same.

            On Fri, Nov 7, 2014 at 10:24 PM, Bram Moolenaar <Bram@...> wrote:

            Tomas Mozes wrote:

            > On Friday, June 14, 2013 2:58:48 PM UTC+2, Christian Wellenbrock wrote:
            > > I attached a yaml file as example. Please open it with vim to test the highlighting speed. Scolling and searching is very slow. Tested on vim 7.3.1106
            >
            > Still valid for 7.4.488.
            >
            > This seems to work much better:
            > https://github.com/stephpy/vim-yaml/blob/master/after/syntax/yaml.vim

            Have you tried with 7.4.497 or later?  It is supposed to fix slowness
            with some patterns.

            --
            Yesterday is history.
            Tomorrow is a mystery.
            Today is a gift.
            That's why it is called 'present'.

             /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net   \\\
            ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\  an exciting new programming language -- http://www.Zimbu.org        ///
             \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

            --
            --
            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 vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • tomas.mozes@...
            Seems a bit better with vim-7.4.712 ... -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are
            Message 5 of 12 , May 22
            • 0 Attachment
              Seems a bit better with vim-7.4.712

              On Monday, November 10, 2014 at 3:11:58 PM UTC+1, Tomas Mozes wrote:
              > Just tried 7.4.507, still the same.
              >
              >
              >
              > On Fri, Nov 7, 2014 at 10:24 PM, Bram Moolenaar <Bram@...> wrote:
              >
              >
              > Tomas Mozes wrote:
              >
              >
              >
              > > On Friday, June 14, 2013 2:58:48 PM UTC+2, Christian Wellenbrock wrote:
              >
              > > > I attached a yaml file as example. Please open it with vim to test the highlighting speed. Scolling and searching is very slow. Tested on vim 7.3.1106
              >
              > >
              >
              > > Still valid for 7.4.488.
              >
              > >
              >
              > > This seems to work much better:
              >
              > > https://github.com/stephpy/vim-yaml/blob/master/after/syntax/yaml.vim
              >
              >
              >
              > Have you tried with 7.4.497 or later?  It is supposed to fix slowness
              >
              > with some patterns.
              >
              >
              >
              > --
              >
              > Yesterday is history.
              >
              > Tomorrow is a mystery.
              >
              > Today is a gift.
              >
              > That's why it is called 'present'.
              >
              >
              >
              >  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net   \\\
              >
              > ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              >
              > \\\  an exciting new programming language -- http://www.Zimbu.org        ///
              >
              >  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

              --
              --
              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 vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            • Dominique Pellé
              ... Viewing your attached yaml file seems fast for me with vim-7.4.729, both with set re=0 or set re=1 . Anyway, looking at vim/runtime/syntax/yaml.vim, I
              Message 6 of 12 , May 22
              • 0 Attachment
                Christian Wellenbrock <christian.wellenbrock@...> wrote:

                > I attached a yaml file as example. Please open it with vim to test
                > the highlighting speed. Scolling and searching is very slow.
                > Tested on vim 7.3.1106

                Viewing your attached yaml file seems fast for me with vim-7.4.729,
                both with 'set re=0' or 'set re=1'.

                Anyway, looking at vim/runtime/syntax/yaml.vim, I see
                several [0-9] in regexp which could be replaced by \d

                This is what :help regexp says:

                === BEGIN QUOTE ===
                - Matching with a collection can be slow, because each character in
                the text has to be compared with each character in the collection.
                Use one of the other atoms above when possible. Example: "\d" is
                much faster than "[0-9]" and matches the same characters.
                === END QUOTE ===

                But I wonder whether this piece of advice is still true.
                In regexp_nfa.c, I see this comment:

                1525 /*
                1526 * Try to reverse engineer character classes. For example,
                1527 * recognize that [0-9] stands for \d and [A-Za-z_] for \h,
                1528 * and perform the necessary substitutions in the NFA.
                1529 */

                So probably [0-9] is as efficient now than \d at least with the new
                NFA regexp engine.

                With 'set re=0', syntime report says:

                TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
                0.173880 349 0 0.001465 0.000498 yamlFloat
                [^[\]{}, \t]\@1<!\%([+-]\=\%(\%(\d[0-
                0.043657 349 0 0.000798 0.000125 yamlInteger
                [^[\]{}, \t]\@1<!\%([+-]\=\%(0\%(b[0-
                0.007699 621 602 0.000065 0.000012 yamlPlainScalar
                \%([^\-?:,[\]{}#&*!|>'"%@`\n\r\uFEFF
                0.004388 621 367 0.000073 0.000007 yamlBlockMappingKey
                \%#=1^\s*\zs\%([^\-?:,[\]{}#&*!|>'"%@

                0.004233 386 0 0.000078 0.000011
                yamlBlockCollectionItemStart ^\s*\zs-\%(\s\+-\)*\s
                0.003241 386 0 0.000043 0.000008 yamlComment
                \%\(^\|\s\)#
                0.003233 349 0 0.000045 0.000009 yamlNull
                [^[\]{}, \t]\@1<!\~[^[\]{}, \t]\@!
                0.002419 386 0 0.000080 0.000006
                yamlBlockMappingMerge ^\s*\zs<<\ze:\%(\s\|$\)
                0.000917 347 347 0.000013 0.000003 yamlKeyValueDelimiter \s*:
                0.000465 347 347 0.000005 0.000001 yamlKeyValueDelimiter \s*:
                0.000312 386 0 0.000007 0.000001 yamlDocumentEnd
                ^\.\.\.\ze\%(\s\|$\)
                0.000193 386 0 0.000002 0.000001 yamlMappingKeyStart ?\ze\s
                0.000166 386 0 0.000002 0.000000 yamlFlowCollection \[
                0.000145 386 0 0.000003 0.000000 yamlDocumentStart
                ^---\ze\%(\s\|$\)
                0.000138 386 0 0.000001 0.000000 yamlDirective
                ^\ze%[^\n\r\uFEFF \t]\+\s\+
                0.000138 386 0 0.000001 0.000000 yamlAnchor
                &[^\n\r\uFEFF \t,[\]{}]\+
                0.000135 386 0 0.000001 0.000000 yamlFlowMapping {
                0.000135 386 0 0.000001 0.000000 yamlAlias
                \*[^\n\r\uFEFF \t,[\]{}]\+
                0.000129 386 0 0.000002 0.000000 yamlFlowString '
                0.000123 386 0 0.000002 0.000000 yamlFlowString "
                0.000115 386 0 0.000003 0.000000 yamlNodeTag
                !<\%(%\x\x\|[[:alnum:]_\-]\|[#/;?:@&=

                Regards
                Dominique

                --
                --
                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 vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/d/optout.
              • Nikolay Pavlov
                ... I have relatively recently send an update. If you see help for :h b:yaml_schema then you have this update because I also added support for different
                Message 7 of 12 , May 22
                • 0 Attachment
                  2015-05-22 11:45 GMT+03:00 Dominique Pellé <dominique.pelle@...>:
                  > Christian Wellenbrock <christian.wellenbrock@...> wrote:
                  >
                  >> I attached a yaml file as example. Please open it with vim to test
                  >> the highlighting speed. Scolling and searching is very slow.
                  >> Tested on vim 7.3.1106
                  >
                  > Viewing your attached yaml file seems fast for me with vim-7.4.729,
                  > both with 'set re=0' or 'set re=1'.

                  I have relatively recently send an update. If you see help for :h
                  b:yaml_schema then you have this update because I also added support
                  for different schemas then.

                  It also contained a number of fixes to the regexes: most notable is
                  that some regexes no longer care about non-printable characters (YAML
                  definition explicitly disallows them in a number of places and my
                  highlighting was as close to YAML definition as possible, so you got a
                  regex `\%([\n\r\uFEFF \t]\@!\p\)` used in *loads* of places and that
                  was very slow).

                  >
                  > Anyway, looking at vim/runtime/syntax/yaml.vim, I see
                  > several [0-9] in regexp which could be replaced by \d
                  >
                  > This is what :help regexp says:
                  >
                  > === BEGIN QUOTE ===
                  > - Matching with a collection can be slow, because each character in
                  > the text has to be compared with each character in the collection.
                  > Use one of the other atoms above when possible. Example: "\d" is
                  > much faster than "[0-9]" and matches the same characters.
                  > === END QUOTE ===
                  >
                  > But I wonder whether this piece of advice is still true.
                  > In regexp_nfa.c, I see this comment:
                  >
                  > 1525 /*
                  > 1526 * Try to reverse engineer character classes. For example,
                  > 1527 * recognize that [0-9] stands for \d and [A-Za-z_] for \h,
                  > 1528 * and perform the necessary substitutions in the NFA.
                  > 1529 */
                  >
                  > So probably [0-9] is as efficient now than \d at least with the new
                  > NFA regexp engine.
                  >
                  > With 'set re=0', syntime report says:
                  >
                  > TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
                  > 0.173880 349 0 0.001465 0.000498 yamlFloat
                  > [^[\]{}, \t]\@1<!\%([+-]\=\%(\%(\d[0-
                  > 0.043657 349 0 0.000798 0.000125 yamlInteger
                  > [^[\]{}, \t]\@1<!\%([+-]\=\%(0\%(b[0-
                  > 0.007699 621 602 0.000065 0.000012 yamlPlainScalar
                  > \%([^\-?:,[\]{}#&*!|>'"%@`\n\r\uFEFF
                  > 0.004388 621 367 0.000073 0.000007 yamlBlockMappingKey
                  > \%#=1^\s*\zs\%([^\-?:,[\]{}#&*!|>'"%@
                  >
                  > 0.004233 386 0 0.000078 0.000011
                  > yamlBlockCollectionItemStart ^\s*\zs-\%(\s\+-\)*\s
                  > 0.003241 386 0 0.000043 0.000008 yamlComment
                  > \%\(^\|\s\)#
                  > 0.003233 349 0 0.000045 0.000009 yamlNull
                  > [^[\]{}, \t]\@1<!\~[^[\]{}, \t]\@!
                  > 0.002419 386 0 0.000080 0.000006
                  > yamlBlockMappingMerge ^\s*\zs<<\ze:\%(\s\|$\)
                  > 0.000917 347 347 0.000013 0.000003 yamlKeyValueDelimiter \s*:
                  > 0.000465 347 347 0.000005 0.000001 yamlKeyValueDelimiter \s*:
                  > 0.000312 386 0 0.000007 0.000001 yamlDocumentEnd
                  > ^\.\.\.\ze\%(\s\|$\)
                  > 0.000193 386 0 0.000002 0.000001 yamlMappingKeyStart ?\ze\s
                  > 0.000166 386 0 0.000002 0.000000 yamlFlowCollection \[
                  > 0.000145 386 0 0.000003 0.000000 yamlDocumentStart
                  > ^---\ze\%(\s\|$\)
                  > 0.000138 386 0 0.000001 0.000000 yamlDirective
                  > ^\ze%[^\n\r\uFEFF \t]\+\s\+
                  > 0.000138 386 0 0.000001 0.000000 yamlAnchor
                  > &[^\n\r\uFEFF \t,[\]{}]\+
                  > 0.000135 386 0 0.000001 0.000000 yamlFlowMapping {
                  > 0.000135 386 0 0.000001 0.000000 yamlAlias
                  > \*[^\n\r\uFEFF \t,[\]{}]\+
                  > 0.000129 386 0 0.000002 0.000000 yamlFlowString '
                  > 0.000123 386 0 0.000002 0.000000 yamlFlowString "
                  > 0.000115 386 0 0.000003 0.000000 yamlNodeTag
                  > !<\%(%\x\x\|[[:alnum:]_\-]\|[#/;?:@&=
                  >
                  > Regards
                  > Dominique
                  >
                  > --
                  > --
                  > 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 vim_dev+unsubscribe@....
                  > For more options, visit https://groups.google.com/d/optout.

                  --
                  --
                  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 vim_dev+unsubscribe@....
                  For more options, visit https://groups.google.com/d/optout.
                Your message has been successfully submitted and would be delivered to recipients shortly.