java - Determining the optimum number of worker threads -


imagine, have x (30 example) number of system. each system has array of entities on has operate (the number of entities system different each) . basically, systems contain algorithms , entities contain data acted upon. each system can specify kind of entities can act upon, entity can operated upon multiple systems.

the systems arranged in chain, meaning run sequentially, not in paralell. called upon in same sequence each time act upon entities (all have call system::process method.

this system chain run 60 times each second.


currently, implemented system runs on single thred, processing it's entities sequentially. i'd have concurrency.

systems not have state, therefore can safely call process methods on multiple threads @ once, given tell each method call on portion of system's entities should work on.

example: determin have 2 cores available, therefore run each system on 2 threads. 1 of threads calls system's process method , tells process 0 20 (indexes of array containing entities), other thread calls same system's process method , tells process 20 40.


now questions: optimal number of threads load should distributed on, taking probable cache size , cores , not account. (maybe decided empirically testing?)

what efficent way manage threads (thread pool etc.)?


Comments