-
Notifications
You must be signed in to change notification settings - Fork 352
Performance Improvements #391
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
Conversation
There's actually a very potentially valid reason to remove the I know the Perhaps we hide it behind some global variable, so it's off by default and the people that want it can turn it on? |
dc82a3d
to
3cb1ea8
Compare
I had no idea about Only regexp literals are noticeably slow for me. I find there's sometimes a lag when I attempt to interact with text following a regexp literal. Does anyone else experience this? |
I've noticed that long lines tend to lag syntax highlighting, but generally the regexes I've used in JS have been pretty small and I have never noticed any serious performance issues, although I think it can be confirmed by the fact that This PR might help a bit with this? I think the reason that |
3cb1ea8
to
1ee5815
Compare
01615e4
to
a4005cc
Compare
Little improvements could be made with trying to replace all the '@=>' and '@<!'. I've got no other suggestions though,I don't know anything about syntax files |
@bounceme do you know what we could replace the look-behinds with? |
according to ':h @<=' and ':h @<!' there are a few methods more performant like '\zs' and limiting the distance of the look behind in 'bytes' |
cba3f07
to
678bb6f
Compare
@bounceme I did end up playing around with the I did add some limiters to the |
b0a741f
to
c2bc4c7
Compare
Not using groups seems to help a bunch with performance
I think these matchers where for functions, and from another era of project ownership. They added a TON of performance overhead, and I could never replicate a scenario where they matched.
We had some special matching for Intl and certain submethods. It seems needless to do this for the following reasons: * The look behind added massive overhead (especially since the rule was not contained) * We never do any special matching for any other global objects, so why these?
Shaved off some average time by removing the groups, which weren't really needed to begin with
The optimizations it provides really doesn't seem to help much and usually just results in weird syntax matching errors unless you run `syntax sync fromstart`
Another match that turns up pretty high in the list of total time spent under `syntime`
I recently learned a bit about the
:syntime
command, and decided to use it to profile our syntax file. I've found some things that I think we can really optimize and I actually got some fairly significant optimizations just in this PR.I am using a fully compiled version of PhaserJS for these benchmarks. I think it's safe to say it's a huge file and I considered it a good way to benchmark performance. As an aside, if there are files you find performance to be pretty bad, you should link it here so I can run these benchmarks and look for other optimizations.
The steps to reproduce the tests are as follows
phaser.js
filegg
to scroll to the top (I would additionally do:set nowrap
as well):syntime on
:syntime report
Here are before and after results for the most intensive selectors:
Before
After
In summary, I found a few rules that seem to be just hanging around not matching anything (probably from a bygone era of function matching) that could easily be removed and also found a few ways to optimize a few of the hotter important contenders.
I am open to more optimization suggestions if you guys have them! I will let this sit for a bit though, to ensure I haven't really broken anything, but so far everything seems very solid.