From: R D. <rd...@cr...> - 2001-09-20 19:12:13
|
Hi all, I am working on a program to simulate stress testing (large number of users) on JDBC connections. I would like to multithread the JDBC operations. I would appreciate some input (samples, tips etc) with anyone that has tried multithreading within jython scripts. Thanks Raj Thanks Raj Datta Professional Services Direct : 408-530-4932 CrossAccess Corp Cell : 408-316-5473 2900 Gordon Ave #100 Fax : 408-735-0328 Santa Clara CA 95051 Email : rd...@cr... |
From: Kevin B. <kb...@ca...> - 2001-09-20 21:07:45
|
Here's a little sample code. --- from threading import Thread from time import time class Job( Thread ): def run( self ): v = 0L for i in xrange( 1, 200000 ): v = v + i self.value = v def _test( n=1 ): jobs = [] for i in range( n ): jobs.append( Job() ) start = time() map( Job.start, jobs ) map( Job.join, jobs ) t = time() - start print "%d: %.3f/%.3f" % (n, t, n and t/n) map( _test, range( 5 )) --- Note that the example above doesn't get a speedup from multiple threads, even on a two CPU box. Of course, if your threads are blocking on a JDBC call, you'll see a speedup... :-) <ObDisc> These are microbenchmarks are thus not worth the electrons it takes to view them. </ObDisc> Although Jython doesn't appear to have a "global interpreter lock" a la CPython, my 2-CPU NT box shows 1 CPU utilized for 1 thread, both CPUs fully utilized for two or more threads, but the times look like: 0: 0.000/0.000 1: 0.719/0.719 2: 1.656/0.828 3: 2.485/0.828 4: 3.329/0.832 So, more threads use more CPU, but are slightly slower, even on a two-CPU box. If you just run the 'run' method of all the jobs, instead of starting a new thread for each of them, you get better times: 0: 0.000/0.000 1: 0.656/0.656 2: 1.297/0.648 3: 1.953/0.651 4: 2.594/0.648 FWIW, the numbers for CPython are much worse (thank that global interpreter lock): 0: 0.000/0.000 1: 0.703/0.703 2: 5.360/2.680 3: 10.969/3.656 4: 11.656/2.914 CPython only uses one CPU, but still incurs the overhead of thread switching - not a pretty picture. These results were obtained on: Jython 2.1a1 on java1.3.0 (JIT: null) Sun JDK 1.3.0 WinNT 4.0 SP 6a 2x PIII 600 kb R Datta wrote: > > Hi all, > > I am working on a program to simulate stress testing (large number of > users) on JDBC connections. I would like to multithread the JDBC operations. > > I would appreciate some input (samples, tips etc) with anyone that has > tried multithreading within jython scripts. > > Thanks > Raj > > Thanks > Raj Datta > Professional Services Direct : 408-530-4932 > CrossAccess Corp Cell : 408-316-5473 > 2900 Gordon Ave #100 Fax : 408-735-0328 > Santa Clara CA 95051 Email : rd...@cr... > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |
From: John M. <joh...@ya...> - 2001-09-21 18:18:50
Attachments:
cThreadTestSerialize.py
jThreadTestSerialize.py
|
Attached is an pair of example programs that compare the single threading in CPython with the true multi-threading by using the Java threads. utah: /home/mudd/misc[1] ls ?ThreadTestSerialize.py cThreadTestSerialize.py jThreadTestSerialize.py utah: /home/mudd/misc[1] cThreadTestSerialize.py self.id=1 self.id=2 self.id=0 Elapsed: 0.1126 sec utah: /home/mudd/misc[1] jThreadTestSerialize.py self.id=2 self.id=0 self.id=1 Elapsed: 0.2870 sec utah: /home/mudd/misc[1] --- R Datta <rd...@cr...> wrote: > Hi all, > > I am working on a program to simulate stress testing (large number of > > users) on JDBC connections. I would like to multithread the JDBC > operations. > > I would appreciate some input (samples, tips etc) with anyone that > has > tried multithreading within jython scripts. > > Thanks > Raj > > Thanks > Raj Datta > Professional Services Direct : > 408-530-4932 > CrossAccess Corp Cell : > 408-316-5473 > 2900 Gordon Ave #100 Fax : 408-735-0328 > Santa Clara CA 95051 Email : > rd...@cr... > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users __________________________________________________ Terrorist Attacks on U.S. - How can you help? Donate cash, emergency relief information http://dailynews.yahoo.com/fc/US/Emergency_Information/ |
From: Frank C. <fc...@pu...> - 2001-09-22 06:36:27
|
Raj: From what I've seen and read about Jython's threading, I think Java threads are the better way to go. In your architecture you would write Java modules that implements Thread and handles all the get/set methods needed to set-up and operate the JDBC connection. Jython would instantiate your JDBC thread (or multiple threads to check scalability) and respond to result sets returned. I think you may find what you're wanting to build in Load, an open-source project I maintain. I am in the process of moving Load to use Jython as a script language. Details are at: http://www.pushtotest.com. And, of course, PushToTest has consulting solutions to add functions needed to test your application. Let me know if we can help. -Frank -- Frank Cohen, founder, PushToTest, www.pushtotest.com, phone: 408 374 7426 Come to PushToTest for Load, a free open-source tool for performance and scalability testing and data migration. > From: R Datta <rd...@cr...> > Date: Thu, 20 Sep 2001 12:11:40 -0700 > To: jyt...@li... > Subject: [Jython-users] Multithreading in Jython > > Hi all, > > I am working on a program to simulate stress testing (large number of > users) on JDBC connections. I would like to multithread the JDBC operations. > > I would appreciate some input (samples, tips etc) with anyone that has > tried multithreading within jython scripts. > > Thanks > Raj > > Thanks > Raj Datta > Professional Services Direct : 408-530-4932 > CrossAccess Corp Cell : 408-316-5473 > 2900 Gordon Ave #100 Fax : 408-735-0328 > Santa Clara CA 95051 Email : rd...@cr... > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |