java - Define Parallel Processing Thread Pool Count and Sleep time -
i need update 550 000 records in table jboss server starting up. need make update backgroundt process multiple threads , parallel processing. application spring, can use initializing bean this.
to perform parallal processing planning use java executor framework.
threadpoolexecutor executor=(threadpoolexecutor)executors.newfixedthreadpool(50); g
how decide thread pool count? think depends on hardware hardware. 16 gb ram , co-i 3 processor.
is practice thread.sleep(20);while processing big update background.
i don't know spring processing specifically, questions seem general enough can still provide possibly inadequate answer.
- generally there's lot of factors go how many threads want. don't want multiple threads on core, that'll slow things down threads start contending cpu time instead of working, core count ceiling, or maybe core count - 1 allow 1 core other tasks run on (so in case maybe 3 or 4 cores, tops, if remember core counts i3 processors right). however, in case i'd guess you're more run i/o and/or memory/cache bottlenecks, since when involved, more slow down program insufficient parallelization. in addition, tasks threads doing affect number of threads can use; if have 1 thread pull data in , 1 thread dump data out after processing, might possible threads share core.
- i'm not sure why idea... use see
thread.sleep()
while processing? i'd guess it'd slow down processing, because you're doing putting threads sleep when working.
in case, i'd wary of parallelizing i/o bound task. you'll need profile see bottlenecks are, before start parallelizing, make sure multiple cores you.
if cpu adding time complete task, then can start parallelizing. then, careful cache issues; try make sure each thread works on totally separate chunk of data (e.g. through threadlocal
) cache/memory issues don't limit performance increases. 1 way work having reader thread dump data queue
worker threads can read threadlocal
structure, process, etc.
i hope helped. i'll keep updating mistakes made pointed out.
Comments
Post a Comment