notepad-plus-plus / notepad-plus-plus

Notepad++ official repository
https://notepad-plus-plus.org/
Other
22.54k stars 4.56k forks source link

Loading large files #14590

Open harryray33 opened 7 months ago

harryray33 commented 7 months ago

NPP takes a very long time in loading large files, and also if I do a find and replace. Is there a way to speed it up?

molsonkiko commented 7 months ago

You need to be more specific. How large is "large"? Do you have plugins enabled? Is syntax coloring turned on?

Please give debug information (?->Debug info from the main menu)

ScrubN commented 5 months ago

How large is "large"

I frequently work with very large unindented/single-line JSON files for another open source project. For me, "large" is about 20-100MB, however np++ tends to get slow at around 1MB (without line breaks).

At that size, syntax coloring does not work, however I do have it enabled for when I work with smaller files.

Here is the debug info output

``` Notepad++ v8.6.5 (64-bit) Build time : Mar 29 2024 - 17:04:43 Path : C:\Program Files\Notepad++\notepad++.exe Command Line : Admin mode : OFF Local Conf mode : OFF Cloud Config : OFF Periodic Backup : ON OS Name : Windows 10 Pro (64-bit OS Version : 22H2 OS Build : 19045.4170 Current ANSI codepage : 1252 Plugins : ComparePlus (1.2) CSScriptNpp (2.0.4) DSpellCheck (1.5) JsonTools (7.1) mimeTools (3.1) NppConverter (4.6) NppExport (0.4) NPPJSONViewer (2.0.7) NppMarkdownPanel (0.7.3) ```

If I had to guess, I would say the lag problem probably lies in the lack of line breaks, as I am able to open and manipulate a 42MB source-generated C# file with much less lag than a 5MB unindented JSON file.

molsonkiko commented 5 months ago

If I had to guess, I would say the lag problem probably lies in the lack of line breaks

I agree that this is probably a lot of the issue. Editing is pretty sluggish for very long lines, especially if word wrap is turned on. I have a pull request that would improve performance in such cases, at the cost of creating issues with parsing of extremely long (more than 32767 character) URLs. You might want to look at that pull request and see if it helps.

I notice you have both JsonTools and NPPJSONViewer installed. It's my opinion that those two plugins are somewhat redundant (JsonTools is much more feature-rich and the tree viewer may load faster for huge files, but NPPJSONViewer is a bit more user-friendly and does formatting significantly faster), and that it probably makes sense to pick whichever one you like more and uninstall the other. I doubt that either plugin is contributing significantly to your performance issues, but it's certainly possible that one or both of them is part of the issue. Maybe you could try uninstalling one, seeing if that helps, then reinstalling that one and uninstalling the other, and seeing if that helps.

If you find that JsonTools is making your performance significantly worse, please let me know. I'm the maintainer of that repo, and I am very interested in ensuring that it has solid performance even for very large files.

ScrubN commented 2 months ago

Just wanted to check back in on this issue.

I have found that the latest version of NP++ (8.6.8) is significantly faster at loading my large single-line JSON files, however editor performance is still a little disappointing. I lowered the large file size limit to accommodate my file (61.2MB) and by trial and error found that both clickable URLs and brace match seemed to create the most lag when scrolling.

It seems to me that NP++ scanning for the appropriate closing brace until it finds it (in my case at the end of the file) causes a lot of extra lag, and it also seems to be constantly rescanning instead of caching the result? Do you know if this is something that could be looked into? Having multiple cursors on braces only highlights the brace under the main cursor, so it seems potentially feasible to cache the brace search result to me.

Despite that though, I'm still very glad that NP++ is now sometimes a viable option for me, and I hope it only gets better.