brianschmitt/relativenumber

Significant performance problem especially navigating large files when moving the cursor.

Closed this issue · 8 comments

I don't know C# but right now, each time the cursor changes lines, this Addon deletes and recreates the UI display labels, as well as calculates other options that rarely change, much less in between cursor line changes (ApplyNumbers()).

Unnecessarily recreating the UI elements on the memory heap so constantly puts much unnecessary stress on performance that is quite visible on older machines, even multi-core generation decent hardware. The UI is quite sluggish.

Among other options, to improve performance, the Label display UI would better be placed in reusable memory pool and only recreated or just reconfigured when relevant properties change. The constant heap reallocations is one of the biggest bottlenecks.

Thanks for the feedback, these are definitely areas that I would like to address to improve performance. Out of curiosity - What size files are you using that you begin to notice the impact?

VIM also runs into performance issues when using relative numbers with large files, do you experience the same lag there?

Now that I've tested while looking for a certain line range, it looked like even just heading up 100 lines the impact gets noticeable enough. In fact it reached a point where it was about the same speed from 100 as it was with 9,000-12,000 line files. Line count may not matter that much after all.. except that there is much more scrolling and jumping around from place to place happening as files get larger.. maybe that made it seem more noticeable.

I then tested out console Vim and gVim with the same files from Visual Studio and it was always the same amount of smoothness for me, no matter the scrolling. Update: I've also just tried Visual Studio again with VsVim disabled - in case that is what you meant - and experienced same results as above. No change.

I'm noticing the same issues with slow line change feedback. I was previously using the ReletiveLineNumbers VS extension and wanted to move to this one because it matches Vim a little closer and also uses my existing theme colors. I ran through the same troubleshooting as @spiralsam and got the same results.

I am a C# developer and would love to help you take a look at this if you want. Just let me know :-)

Help is always appreciated and welcome. :)

I very quickly took a look at the code, but haven't begun working on anything.
I believe its possible to optimize, however, VS handles things a little differently than VIM, which causes some of the complexity, and would be areas to keep an eye on while working on a solution.

For example the key ones that come to mind are:

  • The current line can be off screen - I.E. when in VIM and you scroll up / down (using a mousewheel or scrollbar) the current cursor line always stays within the viewport, in VS it can be located off screen.
  • Codelens and similar features (git info, etc...), introduce additional spacing, but don't count as code lines.
  • I recall some difficulty in dealing with folded code, especially when scrolling the viewport (see first bullet)

Had a recent commit that used pools to allocate, would love to hear if the latest version 1.5.0 addresses your performance concerns.

@brianschmitt I'm installing the plugin now, will report back my findings.

So far with my testing I have not see any of the performance problems we encountered in the previous versions. Great work!

Closing issue. Thanks for the feedback