ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Adaptive ThreadPoolSize?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Jan 05 2017 :  12:43:20  Show Profile  Reply
What happens if I set TImageEnMView.ThreadPoolSize := 10 and a user has only two CPU cores in his computer?

Is there some kind of Adaptive ThreadPoolSize functionality which automatically adjusts the value of ThreadPoolSize to the user's hardware?

nwscomps

185 Posts

Posted - Jan 05 2017 :  15:35:56  Show Profile  Reply
Hello Peter,
to know the number of cpus you can use:

function NumberOfProcessors: Integer;
var
    systemInfo: SYSTEM_INFO;
begin
    GetSystemInfo(systemInfo);
    Result := systemInfo.dwNumberOfProcessors;
end;




Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page

PeterPanino

933 Posts

Posted - Jan 05 2017 :  15:54:53  Show Profile  Reply
Thank you, Francesco.

But what happens if I set TImageEnMView.ThreadPoolSize := 10 and a user has only two CPU cores in his computer?

And should always ThreadPoolSize := NumberOfProcessors * 2?
Go to Top of Page

xequte

38610 Posts

Posted - Jan 05 2017 :  17:10:34  Show Profile  Reply
Hi Peter

ImageEn is not specifically targeting the CPU cores, other than what is done by Windows itself, so I doubt there is particular benefit from correlating ThreadPoolSize to number of processors.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

PeterPanino

933 Posts

Posted - Jan 06 2017 :  06:28:47  Show Profile  Reply
Thank you, Nigel. So what is the suggested ThreadPoolSize value? Are there any circumstances which influence this decision? Or can I set the ThreadPoolSize value to literally ANY value independently from the user's hardware?
Go to Top of Page

nwscomps

185 Posts

Posted - Jan 06 2017 :  08:37:54  Show Profile  Reply
Peter, for normal usage I would recommend something like this formula:

PoolSize := max(5, min(12, NCpu * 2 -1));

This with optimal cpu usage by windows would typically load a couple of threads per cpu, reserving extra cpu power for all the rest.

I would put a higher limit on the number of threads, because if the files that are being loaded require too much cpu (like in my tests raw files), you can have the threads drain all the cpu power.

PS my tests are based on my ThumbsBrowser component, not on TImageenmview, but since I expect the loading mechanism to be somewhat similar, it can be applied to TImageenmview as well.
In Thumbsbrowser you have another variable called MultithreadTimeout that is number of millisecs to wait before creating extra threads if the threads in the pool do not complete the job in the allocated time. This can allocate a number of extra threads if thumbnails are too slow to load like in the mentioned raw files test, in order to display eventually those thumbs that are faster to load. In this scenario there is an internal check on the maximum amount of extra threads not to be exceeded.

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page

PeterPanino

933 Posts

Posted - Jan 06 2017 :  11:34:55  Show Profile  Reply
From what I read on your website, your ThumbsBrowser component looks very interesting. When it "adds thumbnails from memory", is this done in multi-threading mode? Can I add thumbnail-bitmaps to a FIFO multi-bitmap-buffer provided by my own routine and your component takes them out from the buffer and adds them to the Thumbsbrowser in multi-threading mode?
Go to Top of Page

PeterPanino

933 Posts

Posted - Jan 06 2017 :  12:07:53  Show Profile  Reply
Francesco, since the contact form on your website does not work:

What I would also need: Does ThumbsBrowser support creating thumbs from web pages (in a multi-threading mode)? For example, I would provide a list of web-page URLs and ThumbsBrowser is filled with the thumbs of those web pages.
Go to Top of Page

nwscomps

185 Posts

Posted - Jan 06 2017 :  15:30:13  Show Profile  Reply
Peter, I have answered to your message from the contact form. (also now the redirect in the contact form should be fixed)

About the first question, I have replied in the email.
About the internet urls they are read in multithreading, but the list of urls must be provided by the user.


Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: