Feature Request: Parallel Processing (Multithreading)
-
No sure why so long time have passed and no implementation of Parallel Processing or Multithreading. is it difficult to implement or what?. i am having 20 core CPU and just one core Notepad ++ is utilizing and taking forever. please update if this is possible or not possible.
-
Parallel processing of what?
A single CPU has enough power to handle your keyboard typing.Most users of Notepad++ do not experience high CPU utilization or long delays. The few that did (lookup the forum) usually found a faulty plugin or wrong usage paradigm that was easy to fix.
Multi threading is not a feature. It is a tool in the hands of the developer to be applied to specific parts of the application. And for most tasks it is far less helpful than people tend to think.
So the question is whether there is a specific task that bothers you. For example: Find in files. For which the answer is: “Yes it is difficult to implement”.
-
-
@gstavi said in Feature Request: Parallel Processing (Multithreading):
Parallel processing of what?
In my humble opinion.I can give you an exemple.
Right now I’m doing a Replace in a file with 1 million lines… the CPU used is at max 13% that is just a single core.
It could speed up a lot of tasks that take like 20-30 minutes to do in daily tasks… that is a lot of save.After all you are doing only that and need it to finish to go ahead… so using the 100% of the CPU should be ideal for any app including a text editor.
We are in 2024 and as things go in terms of CPU cores then I think it is something to be in the plan for that excellent app.
PS. While you are doing these tasks the App UI freezes and the only way to know it is doing the job is looking at the CPU use in Task Manager.
-
@ethpsantos said in Feature Request: Parallel Processing (Multithreading):
Right now I’m doing a Replace in a file with 1 million lines… the CPU used is at max 13% that is just a single core.
It could speed up a lot of tasks that take like 20-30 minutes to do in daily tasks… that is a lot of save.It seems to me very unlikely that multi-threading for tasks like this will ever be introduced to Notepad++. It would be difficult, and probably wouldn’t help nearly as much as you think, since the underlying edit control (Scintilla) is single-threaded.
If you are using Notepad++ daily to do tasks that run for 20-30 minutes without user interaction, it is likely that you can find a better tool for the job. Consider something like sed. I doubt that it is multi-threaded, and it would take you some time to learn how to use it, but it would surely accomplish the sort of task you describe much more quickly.
-
Doing a multi-threaded search and replace isn’t going to be is trivial as yuo think it is. Multithreading works best when the items being processed are not closely related. Unfortunately chunks of text in a single file are actually quite closely related.
For a general replace ‘some text’ with ‘different stuff that will probably be a different length’, you have to ensure that none of the threads overwrite another threads data, so they’ll need to do a lot of synchronisation.
Now it is possible that for your particular case, you could divide the text up into individual sentences and operate on each sentence in parallel (and then tie them all back up into the buffer afterwards).
But that is a very specific usecase, and not applicable to every search and replace by any means.
It’d be a lot of work to do that generally.
It is worth noting that the first thing you should learn about threads is to try and find another way of solving your problem. They are tricky little beasts.
-
@ThosRTanner said in Feature Request: Parallel Processing (Multithreading):
Doing a multi-threaded search and replace isn’t going to be is trivial as yuo think it is
It wouldn’t be too hard (in principle) for Find in Files,
which is likelybut of course that’s not the main thing the OP was talking about. Just spin up N threads to read X files and assign X/N files to each thread.In practice, I’ve seen the source code for the find/replace dialog, and it is filled to the brim with global shared state, and thus potential race conditions. If Notepad++ had automated UI tests, some experienced programmer could be pretty cavalier about tearing out the whole edifice and starting over from scratch, but of course no such UI tests exist and thus I don’t think even a programmer with considerable skill in multithreaded programming could fix this without introducing unacceptable risk of corrupting files while executing a multithreaded Replace in Files action.
There’s another element here, which is ease of debugging. Notepad++ doesn’t have any built-in logging mechanism, and anyone who’s ever tried using an interactive debugger on a multithreaded program knows that log files are the only way to debug those programs without going insane.
-
@nft-3000 said:
No sure why so long time have passed and no implementation of Parallel Processing or Multithreading. is it difficult to implement or what?. i am having 20 core CPU and just one core Notepad ++ is utilizing and taking forever. please update if this is possible or not possible.
and @ethpsantos said:
Right now I’m doing a Replace in a file with 1 million lines… the CPU used is at max 13% that is just a single core.
It could speed up a lot of tasks that take like 20-30 minutes to do in daily tasks… that is a lot of save.Nearly all tools, including Notepad++, are single threaded. However, you can start 20 instances of Notepad++, or nearly any tool, and to have them do things in parallel, if that’s your desire. For Notepad++ you can either:
- Set up 20 separate portable copies and to start them using the
-multiInst
command line argument. This provides the best isolation between your copies so that they don’t step on each other. - Set up one portable copy and have 20 separate settings folders. Start your copies using the
-settingsDir
and-multiInst
command line options. This provides nearly the same level of isolation between the copies. Some plugins, such asNppConverter
seem to ignore-settingsDir
and so this is something you should be alert for when setting up scripts that will be run for each each copy of Notepad++.
NppExec and PythonScript, and probably other plugins, support running a script when Notepad++ is started. That’s how you will get your 20 copies of Notepad++ to do whatever you want as they are started.
As you will have 20 config.xml files you can adjust each of the 20 copies to have a small window on your monitor(s) so that you can view the progress of all 20 copies doing things at once.
- Set up 20 separate portable copies and to start them using the