jython?

8 views
Skip to first unread message

Arthur Edelstein

unread,
Jun 11, 2010, 2:26:14 AM6/11/10
to pycsp
Dear all,

Has anyone tried pycsp with jython? Will the threads module work,
given that jython is multithreaded?

Arthur

Rune M. Friborg

unread,
Jun 11, 2010, 2:39:57 AM6/11/10
to pycsp
Hi Author,

It has worked, but is not currently supported. The effort to do so,
should be quite small.

In the threads version of PyCSP we take advantage of the GIL, to avoid
extra locking when handling lists.

Jython don't like this, since it has no GIL:

# /Users/runef/jython2.5.1/bin/jython Commstime.py
python Commstime.py [ threads | processes | greenlets | net ]
Using version (0, 7, 0, 'threads')
----------- run 1/10 -------------
Running commstime test
Exception in thread Thread:Traceback (most recent call last):
File "/Users/runef/jython2.5.1/Lib/threading.py", line 178, in
_Thread__bootstrap
self.run()
File "../pycsp/threads/process.py", line 81, in run
self.fn(*self.args, **self.kwargs)
File "../pycsp/threads/process.py", line 81, in run
self.fn(*self.args, **self.kwargs)
File "Commstime.py", line 39, in Delta2
cout2(t)
File "../pycsp/threads/channel.py", line 179, in _write
self.post_write(req)
File "../pycsp/threads/channel.py", line 200, in post_write
self.match()
File "../pycsp/threads/channel.py", line 207, in match
for r in self.readqueue[:]: # ATOMIC copy
ConcurrentModificationException:
java.util.ConcurrentModificationException

Best Regards, Rune

On Jun 11, 8:26 am, Arthur Edelstein <arthuredelst...@gmail.com>
wrote:

Rune Møllegaard Friborg

unread,
Sep 1, 2010, 10:24:31 AM9/1/10
to py...@googlegroups.com
Hi,

I should mention that Jython is now supported in the threads module of PyCSP.

Currently available in svn trunk.

Notice in the Commstime benchmark that PyCSP benefits from
multithreading and jit compilation in Jython.


$ java -jar ~/jython2.5.1/jython.jar Commstime.py threads
Using version (0, 7, 1, 'threads')


----------- run 1/10 -------------
Running commstime test

DT = 2.153000.
Time per ch : 2.153000/(4*5000) = 0.000108 s = 107.650006 us
consumer done, posioning channel
----------- run 2/10 -------------
Running commstime test
DT = 0.888000.
Time per ch : 0.888000/(4*5000) = 0.000044 s = 44.399989 us
consumer done, posioning channel
----------- run 3/10 -------------
Running commstime test
DT = 0.995000.
Time per ch : 0.995000/(4*5000) = 0.000050 s = 49.750006 us
consumer done, posioning channel
----------- run 4/10 -------------
Running commstime test
DT = 0.855000.
Time per ch : 0.855000/(4*5000) = 0.000043 s = 42.750001 us
consumer done, posioning channel
----------- run 5/10 -------------
Running commstime test
DT = 0.827000.
Time per ch : 0.827000/(4*5000) = 0.000041 s = 41.349995 us
consumer done, posioning channel
----------- run 6/10 -------------
Running commstime test
DT = 0.818000.
Time per ch : 0.818000/(4*5000) = 0.000041 s = 40.899992 us
consumer done, posioning channel
----------- run 7/10 -------------
Running commstime test
DT = 0.825000.
Time per ch : 0.825000/(4*5000) = 0.000041 s = 41.250002 us
consumer done, posioning channel
----------- run 8/10 -------------
Running commstime test
DT = 0.897000.
Time per ch : 0.897000/(4*5000) = 0.000045 s = 44.850004 us
consumer done, posioning channel
----------- run 9/10 -------------
Running commstime test
DT = 0.861000.
Time per ch : 0.861000/(4*5000) = 0.000043 s = 43.050003 us
consumer done, posioning channel
----------- run 10/10 -------------
Running commstime test
DT = 0.834000.
Time per ch : 0.834000/(4*5000) = 0.000042 s = 41.700006 us
consumer done, posioning channel

Cheers,
Rune

On Jun 11, 8:26 am, Arthur Edelstein <arthuredelst...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages