Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
Tom1
Messages: 1080
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 #58406 is a reply to message #58325] Wed, 18 May 2022 10:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13623
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 22 April 2022 23:32
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


Cannot reproduce.

That said, FileSel is loading icons for .exe files in the background. Could that be an explanation?
Re: FileSel takes quite a lot of CPU on Windows [message #58418 is a reply to message #58406] Wed, 18 May 2022 12:30 Go to previous messageGo to next message
Tom1
Messages: 1080
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 Go to previous messageGo to next message
Tom1
Messages: 1080
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 Go to previous messageGo to next message
Tom1
Messages: 1080
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():
	load_exe_icons=true;


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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13623
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 18 May 2022 13:42
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


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 Go to previous messageGo to next message
Tom1
Messages: 1080
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 #58425 is a reply to message #58424] Thu, 19 May 2022 09:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13623
Registered: November 2005
Ultimate Member
Tom1 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.
Re: FileSel takes quite a lot of CPU on Windows [message #58426 is a reply to message #58425] Thu, 19 May 2022 10:30 Go to previous messageGo to next message
Tom1
Messages: 1080
Registered: March 2007
Senior Contributor
mirek wrote on Thu, 19 May 2022 10:55
Tom1 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
Re: FileSel takes quite a lot of CPU on Windows [message #58427 is a reply to message #58426] Thu, 19 May 2022 10:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13623
Registered: November 2005
Ultimate Member
FileSel::NoExeIcons
Re: FileSel takes quite a lot of CPU on Windows [message #58430 is a reply to message #58427] Thu, 19 May 2022 11:08 Go to previous message
Tom1
Messages: 1080
Registered: March 2007
Senior Contributor
Very good! Thanks Mirek!

Best regards,

Tom
Previous Topic: FileSelNative::AllFilesType() doesn't show files without extensions on Linux
Goto Forum:
  


Current Time: Thu May 26 23:02:49 CEST 2022

Total time taken to generate the page: 0.02434 seconds