-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perf issues #77
Comments
Hi @slonoed, Could you provide an example file so I can confirm locally? This is the first I've heard of a serious performance issue with the syntax file. |
The clojureSymbol regex is consistently the top item for me too when running with It is particularly bad if I have a long line of text and/or s-expressions, and try and delete a few characters using Switching syntax off and deleting the same code fragment with |
I do believe that you and @slonoed are having issues, but I don't see them locally. I enjoy debugging performance issues, but I won't be able to do that without a reproducible example. For instance,
On my machine, this operation is quite snappy, so I can only guess at what might be the problem. |
I'm also seeing some typing and scrolling delays lately. I'm using neovim. I opened this file https://github.com/http-kit/http-kit/blob/master/src/org/httpkit/client.clj and set clojureSymbol was easily the slowest call in the report. TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN |
Thanks @morrifeldman Performance is still pretty good on my machine for the linked file, but I can see how scrolling would feel slow on a laptop. I'll have a stab at optimizing the syntax file today. |
Removing the 35 clojureNumber passes for each possible custom radix halves the syntax matching time overall. Please try the following issue branch: https://github.com/guns/vim-clojure-static/tree/issue-77 You can use the new syntax benchmark script $ cd vim-clojure-static/clj/bin/
$ ./syntime path-to-my-clojure-file.clj
$ ls
syntime report-2017-02-07-21-21-48.log |
Hi, dwelling on: syntax match clojureSymbol "\v%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!#$%&*_+=|'<.>/?-]|[^\x00-\x7F]))*[#:]@<!" I'm familiar with regexes in general, but not the vim-flavour specifically - and have a couple of questions:
If I remove the syntax match clojureSymbol "\v[\a!$&*_+=|<.>?-]+:?[\a\d!#$%&*_+=|'<.>/?-]*[#:]@<!" (not claiming this is valid or exactly equivalent, but you get the idea - is this viable?) slowest 59 vs 928 The (snipped) syntime comes in as:
vs previously:
|
Makes the pattern "very-magic", so closer to PCRE. See
It is non capturing grouping, like
Yes. See 712be9a
Using the builtin char classes is a good idea. I'll have a look now. |
Urgh, I was getting frustrated searching google for for details on \v, %(, etc ... I didn't even consider the built-in docs... Oh well :) Is there a \u (or equivalent) that can be used instead of [^\x00-\x7F] for unicode matching? |
Removing the multibyte character check and using character classes in place of character ranges produces the following pattern: syntax match clojureSymbol "\v[[:alpha:]!$&*_+=|<.>?-]+%(:?[[:alnum:]!#$%&*_+=|'<.>/?-])*[#:]@<!" Note that Using the new ORIGINAL
WITH CHARACTER CLASSES
As you can see, there is no discernible performance difference after removing the multibyte check and replacing character ranges with character classes. Furthermore, removing the In contrast, the changes in the issue77 branch reduce the running time to 43% of current performance without changing the |
I've been testing syntime with client.clj (from https://github.com/http-kit/http-kit/blob/master/src/org/httpkit/client.clj) and this clearly taxes the
Removing it entirely, the total time drops from 0.79156 to 0.026007:
Where I put the carat indicator: syntax match clojureSymbol "\v%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!#$%&*_+=|'<.>/?-]|[^\x00-\x7F]))*[#:]@<!"
^ does this need to be similarly, can the Is it just that it is doing unnecessary backtracking? |
Actually, it seems like
Without knowing the full impact of removing
|
@guns Oh, I should say all the ponderings/investigations of |
Nice catch! Looks like
|
Branch |
@guns - any thoughts as to when that branch will get merged into master? |
I too have noticed perf issues with Clojure syntax on a 2-month-old top-of-the-line MacBook Pro using regular vim. Amazing work, looking forward to this being merged! For those using neovim - does perf improve over regular vim? I'm thinking of switching. |
Hi @guns, is https://github.com/guns/vim-clojure-static/tree/issue-77 ready to merge? |
I hate to pile on, but I'd love to see some progress in this arena. Manually merging in some of the changes from issue-77 is great, but it's always nice to be official. |
Looks like this plugin has issue with performance. I have delays when typing (up to 3 second).
I disabled all plugins and found than clojureSymbol regex take most time when working with clojure file.
vim version output
My question is: can this regex be rewrited? Or this is already best solution?
The text was updated successfully, but these errors were encountered: