Home » U++ Library support » FileSel&FileList, Path » FileSel takes quite a lot of CPU on Windows
FileSel takes quite a lot of CPU on Windows [message #58325] |
Fri, 22 April 2022 23:32 |
Tom1
Messages: 1242 Registered: March 2007
|
Senior Contributor |
|
|
Hi,
Using FileSel (e.g. FileSel::ExecuteOpen()) takes a whole lot of CPU cycles on the background and it continues to dominate one CPU core for about half a minute after opening the FileSel dialog. This is on Windows. No such issue on Linux. You can see it on the Windows Task Manager by observing CPU usage (of e.g. UWord) when opening a file using FileSel. I looked back and noticed that this was already present in 2021.1 and remains there in 2022.1rc3.
Best regards,
Tom
|
|
|
|
Re: FileSel takes quite a lot of CPU on Windows [message #58418 is a reply to message #58406] |
Wed, 18 May 2022 12:30 |
Tom1
Messages: 1242 Registered: March 2007
|
Senior Contributor |
|
|
mirek wrote on Wed, 18 May 2022 11:11
That said, FileSel is loading icons for .exe files in the background. Could that be an explanation?
It might... I did some testing and found out that if I have LAN enabled (as I normally do), the excessive CPU loading is present. If I disable network access, there is no such problem. It is not enough if I just disconnect the network drive mappings (SMB).
[EDIT: Irrelevant question removed.]
Best regards,
Tom
[Updated on: Wed, 18 May 2022 13:57] Report message to a moderator
|
|
|
Re: FileSel takes quite a lot of CPU on Windows [message #58419 is a reply to message #58418] |
Wed, 18 May 2022 13:42 |
Tom1
Messages: 1242 Registered: March 2007
|
Senior Contributor |
|
|
Mirek,
OK, now I can see it: I have a shortcut (link) on my desktop to an exe file on my server. So, the shortcut ("program1.exe - shortcut.lnk") points to "\\nas\share\program.exe". When I open FileSel, this causes the enormous CPU loading for quite some time.
If I map the \\nas\share to a network drive s: and change the shortcut to point to s:\program.exe, then the scanning proceeds much faster, just in a couple of seconds of CPU core domination.
How about making exe file icon loading optional through user configurable flag, such as: FileSel& LoadExeFileIcons(bool f); ?
BTW: Is it essential to load icons for network files at all?
Best regards,
Tom
|
|
|
Re: FileSel takes quite a lot of CPU on Windows [message #58420 is a reply to message #58419] |
Wed, 18 May 2022 15:01 |
Tom1
Messages: 1242 Registered: March 2007
|
Senior Contributor |
|
|
Mirek,
It looks like a flag to avoid lookup of exe icons helps here. It needs just four lines of code added/changed in FileSel.
Add to class FileSel in FileSel.h:
bool load_exe_icons;
FileSel& LoadExeIcons(bool b = true) { load_exe_icons = b; return *this; }
Add if condition to end of FileSel::SearchLoad() in FileSel.cpp:
if(load_exe_icons) lazyicons.Start(list, d, WhenIcon);
Reset flag default value added in FileSel::FileSel():
For my use, I would nearly always use LoadExeIcons(false); -- even as default -- as my default usage is to open documents, not exe files. However, setting load_exe_icons=true; by default, retains original default behavior.
Best regards,
Tom
[Updated on: Wed, 18 May 2022 15:06] Report message to a moderator
|
|
|
Re: FileSel takes quite a lot of CPU on Windows [message #58422 is a reply to message #58419] |
Thu, 19 May 2022 08:57 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Wed, 18 May 2022 13:42Mirek,
OK, now I can see it: I have a shortcut (link) on my desktop to an exe file on my server. So, the shortcut ("program1.exe - shortcut.lnk") points to "\\nas\share\program.exe". When I open FileSel, this causes the enormous CPU loading for quite some time.
If I map the \\nas\share to a network drive s: and change the shortcut to point to s:\program.exe, then the scanning proceeds much faster, just in a couple of seconds of CPU core domination.
How about making exe file icon loading optional through user configurable flag, such as: FileSel& LoadExeFileIcons(bool f); ?
BTW: Is it essential to load icons for network files at all?
Best regards,
Tom
Uhm, is this feature causing any problems? I mean, ok, CPU is high (for whatever reason, but my guess it is windows fault), but it runs in background and does not affect main thread. And I believe users do expect to see .exe icons after all...
Mirek
|
|
|
Re: FileSel takes quite a lot of CPU on Windows [message #58424 is a reply to message #58422] |
Thu, 19 May 2022 09:48 |
Tom1
Messages: 1242 Registered: March 2007
|
Senior Contributor |
|
|
Mirek,
I do understand that many/most users are happy with their applications when the computer interacts with them in a timely manner and show a nice GUI. But in my case some of my applications work on various timing sensitive external data streams (data-acquisition, network, serial, even low-latency audio processing) that just cannot wait for CPU without unwanted consequences. Therefore, I prefer to minimize all unnecessary loading of any system resources to ensure that the timing sensitive background tasks proceed without glitches.
I guess the flag solution (LoadExeIcons()) shown above would serve both worlds.
Additionally, in any case it would not hurt to stop the background icon harvesting when the dialog is closed by the user.
Best regards,
Tom
|
|
|
|
Re: FileSel takes quite a lot of CPU on Windows [message #58426 is a reply to message #58425] |
Thu, 19 May 2022 10:30 |
Tom1
Messages: 1242 Registered: March 2007
|
Senior Contributor |
|
|
mirek wrote on Thu, 19 May 2022 10:55Tom1 wrote on Thu, 19 May 2022 09:48
Additionally, in any case it would not hurt to stop the background icon harvesting when the dialog is closed by the user.
Cannot do that - thread is deep in Win32, there is not good way how to interrupt it.
OK, I see.
Hope you can include the LoadExeIcons() though.
Best regards,
Tom
|
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 01:33:57 CEST 2024
Total time taken to generate the page: 0.07004 seconds
|