Notepad-plus-plus: The problem of high CPU occupancy

Created on 21 Dec 2017  ·  3Comments  ·  Source: notepad-plus-plus/notepad-plus-plus


Description of the Issue

Open a larger file, for example: a 10MB size file.

Open Windows Task Manager, Locate to notepad++.exe,
Hold down the "Down direction key" in notepad++, the CPU occupancy rate will exceed 6%. (My CPU is i7 6700k)

The same operation in Windows Notepad is only 1% of CPU occupancy rate.

Steps to Reproduce the Issue

  1. Open a larger file, for example: a 10MB size file
  2. Open Windows Task Manager, Locate to notepad++.exe
  3. Hold down the "Down direction key" in notepad++

Expected Behavior

The CPU occupancy is less than 1%

Actual Behavior

The CPU occupancy rate is 2%-6%

Debug Information

Notepad++ v7.5.3 (64-bit)
Build time : Dec 5 2017 - 10:47:54
Path : E:notepad++notepad++.exe
Admin mode : OFF
Local Conf mode : ON
OS : Windows 7 (64-bit)
Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll

Most helpful comment

Can code be made more efficient? Sure...most code can with proper profiling, algorithm selection, and optimization.

However, there is no argument as to why "2%-6%" is bad. Notepad++ will always require more CPU usage than Windows Notepad and should not be used as a benchmark. It doesn't make sense to compare the two.

There are numerous Notepad++ features that can affect CPU usage:

  • Syntax highlighting - Some are much more computationally expensive than others
  • Code folding
  • Word wrapping - Scintilla has to work very hard to determine where lines should be wrapped
  • Displaying margins
  • Smart Highlighting - Searches the text on the screen for any new matches
  • URL detection - Searches the text on the screen for anything that looks like a URL
  • Indentation guidelines
  • Brace matching

All these require processing of the text beyond just, "scroll to the next line and draw it on the screen". Also, plugins can also be a factor as those can require additional CPU resources, so disable those if you want a better idea of what Notepad++ is using.

Notepad++ uses Scintilla for the text handling/processing so some optimizations might be better directed toward that project. That is probably where > 75% of the CPU usage is required for Notepad++.

So to make this report valid/useful, I'd recommend actually trying to profile the code and see if there are areas that could be improved rather than a blanket statement of Notepad++ needs more CPU than Notepad.

All 3 comments

I didn't know that the spec for Notepad++ was.....Windows Notepad.....Gulp!

@sasumner Ok, it's not bug, but obsessive-compulsive disorder looks less comfortable...

Can code be made more efficient? Sure...most code can with proper profiling, algorithm selection, and optimization.

However, there is no argument as to why "2%-6%" is bad. Notepad++ will always require more CPU usage than Windows Notepad and should not be used as a benchmark. It doesn't make sense to compare the two.

There are numerous Notepad++ features that can affect CPU usage:

  • Syntax highlighting - Some are much more computationally expensive than others
  • Code folding
  • Word wrapping - Scintilla has to work very hard to determine where lines should be wrapped
  • Displaying margins
  • Smart Highlighting - Searches the text on the screen for any new matches
  • URL detection - Searches the text on the screen for anything that looks like a URL
  • Indentation guidelines
  • Brace matching

All these require processing of the text beyond just, "scroll to the next line and draw it on the screen". Also, plugins can also be a factor as those can require additional CPU resources, so disable those if you want a better idea of what Notepad++ is using.

Notepad++ uses Scintilla for the text handling/processing so some optimizations might be better directed toward that project. That is probably where > 75% of the CPU usage is required for Notepad++.

So to make this report valid/useful, I'd recommend actually trying to profile the code and see if there are areas that could be improved rather than a blanket statement of Notepad++ needs more CPU than Notepad.

Was this page helpful?
0 / 5 - 0 ratings