• Post Reply Bookmark Topic Watch Topic
  • New Topic

running large number of java threads  RSS feed

 
Lee Rong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i have a p2p simulation which basically runs thousands of java threads as peers to simulate peer interaction in a p2p network. currently, the maximum number of peers i can run is around 7000 on one machine. i tried to fiddling with the jvm parameters such as -xmx and -xms but still couldn't break the 7000 barrier. i also tried to run the program on different machines and os (i.e., xp and linux) and again without any success.

i have been looking around at distributed java implementation such as ProActive but after changing my code, it gives me hard-to-detect deadlocks due to the different implementation of threads in ProActive.

so is there any way for me to increase the number of threads for the simulation on one single machine? or if it has to be distributed, are there any packages that require minimum modifications to my code and is approved to be stable for such program?

thanks heaps,

lee
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally I think it is astonishing that you were able to get 7000 Threadss runing. There is an irreducable amount of overhead involved in each Thread and in each thread context switch - also I would expect that there will be limits on the number of simultaneous open sockets the OS will support.
Are these peers all talking to each other on the same machine?
Bill
 
Jared Richardson
author
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
7,000 sounds pretty darn good to me. However, here's an idea. Have you tried tweaking the Java thread stack size?

Check this URL: Simple Thread

Scroll down to this block:


Be aware of the -X memory options available with the JVM, which affords the easiest and most effective performance increase. Effective because allocating and freeing memory is the slowest operation for the JVM.
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size


Try a smaller java thread stack size to get more threads into your existing memory.

Of course, you may just be running out of native threads on your OS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!