Control nb of threads - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Control nb of threads (/Thread-Control-nb-of-threads) |
Control nb of threads - ChameleonScales - 10-17-2021 A plug-in I'm developing (in pythonfu), which does batch processing on multiple xcf files, performs several times faster when I use ~3 threads compared to when I use all my CPU threads (32) or some good percentage of it (24). Not sure why, I guess either the RAM or SSD drive is choking when I use too many threads. Right now I can control the number of threads by going in Gimp's preferences but I would like to keep it high when I use Gimp's interface and low for my plug-in, so I would need a way to change or override it from within the code of my plug-in, so as to not do it manually every time I use it. I didn't find a config file where this could be changed via text replacement, nor did I find any command for it. Also I can't do it by forcing the entire plug-in to use less threads because it contains a progress bar which needs some CPU power in order to not freeze. Is it at all possible ? num-processors - Gimphried - 10-17-2021 Hello ChameleonScales Gimp menu Edit > Preferences > System Resources > Resource Consumption > Number of thread to use: 5 C:\Users\YourWindowsUserName\AppData\Roaming\GIMP\2.10\gimprc is updated with: Code: (num-processors 5) num-processors: Sets how many processors GIMP should try to use simultaneously. This is an integer value. Related topic: Multithread python plug-in? Regards. RE: Control nb of threads - ChameleonScales - 10-17-2021 Thanks! I was searching through the files with the word "thread" and not "processor" so I didn't find it (would be neat if it had a consistent name btw). The other topic you linked is one I also started but is not really the same. It's about running multiple instances of Gimp, each one on a different thread. This one is about controlling the number of threads in one instance of Gimp. RE: Control nb of threads - Ofnuts - 10-18-2021 (10-17-2021, 12:14 PM)ChameleonScales Wrote: A plug-in I'm developing (in pythonfu), which does batch processing on multiple xcf files, performs several times faster when I use ~3 threads compared to when I use all my CPU threads (32) or some good percentage of it (24). Not sure why, I guess either the RAM or SSD drive is choking when I use too many threads. Yes, you can end up having I/O contention. And if your disk is encrypted you need some CPU for encoding. Also, Python itself isn't really multi-threading due to the GIL, so the performance improvement you see with a low thread count is possibly just Python being able to overlap IO and processing (which still means that there is only one thread using the CPU). On the other hand nothing says that interactive Gimp benefits from more than a handful of threads. |