NetTalk Central

Author Topic: Thread pool limit ignored?  (Read 3550 times)

jlavera

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
Thread pool limit ignored?
« on: April 13, 2020, 03:14:06 PM »
Hi, I have a web rest server (latest version, 11.35), I specify in the settings a limit of 500 pools, and I see it is assigned in the code;

  If 500 > 0
    s_web.SetPoolSize(500)
  End

However, when I run the program with the statistics window opened, although I have over 140 threads and 150 sessions, the pool number always goes up just to 100 (which happens to be the default).

Is the thread pool manual limit really working, in that case what I might be missing?

Kind regards,
Jorge Lavera

jlavera

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
Re: Thread pool limit ignored?
« Reply #1 on: April 13, 2020, 07:02:33 PM »
I was following the code, I think the problem is MaxThreadPool ? The SetPoolSize procedure sets the pool size according to what I put in the template, but inside this procedure says

  if p_Size > MaxThreadPool then p_size = MaxThreadPool.

And MaxThreadPool is an equate with value of 100!

Shouldn't MaxThreadPool have a higher value? Or what is the purpose of the thread pool limit in the template?

Kind regards,
Jorge Lavera

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Thread pool limit ignored?
« Reply #2 on: April 13, 2020, 09:37:48 PM »
Hi Jorge,

The primary limit in any 32 bit program (aka all Clarion programs) is Ram.
Each thread consumes ram for all your global threaded objects and tables etc.
Every program will be different, but you will need to experiment to see what sort of numbers your program supports.

Secondly, the number of cores in the actual machine impacts how many threads are "useful". For example if the machine has 100 cores, then obviously 100 threads are all running on their own core, and so that's great.

However if you have 4 cores, and 100 threads, then that's 25 threads per core. At some point the overhead of managing so many threads per core slows down each core, and so gains are marginal. Again, that place will be very dependent on your CPU.

You can of course extend the equate and experiment to find out the number that is right for your app.

cheers
Bruce

jlavera

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
Re: Thread pool limit ignored?
« Reply #3 on: April 15, 2020, 11:52:45 AM »
Hi, Bruce.

I know in my scenario a number bigger than 100 is better. My point is, the value entered in the user template interface (which defaults to 100) is ignored if it is higher than 100 (because of the equate)... Then what's the point of this number? It is only to enter lower values?
I changed the equate manually in the nettlak source, the problem is now I have to remember to do that with each template update. What is the problem to have a higher equate limit, if the effective number is being taken from what the programmer enter in the template window? Keep in mind I'm talking about the pools, not the bare threads.

Kind regards,
Jorge Lavera

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Thread pool limit ignored?
« Reply #4 on: April 16, 2020, 11:09:36 PM »
Hi Jorge,

>> Then what's the point of this [template] number? It is only to enter lower values?

yes.

>> What is the problem to have a higher equate limit,

The easiest way to understand what the equate does, is to search for it in the code. Most "Max" type equates are used for things like determining the size of arrays, and so in this case it's no different;

in netweb.inc
ThreadPool                group(NetThreadPoolType),Dim(MaxThreadPool)
                          end

>> the problem is now I have to remember to do that with each template update.

If your program you can add a line of code, say on startup, something like
 
  If MaxThreadPool < 500
    stop('You Jorge, bump MaxPoolThread to at least 500')
  End

That way if you forget the program will remind you.

cheers
Bruce