Bram Stolk - 2006-01-03

I've written a ping-pong test program that
creates a dead lock when doing a three-way
pingpong.
Code follows:

  Bram

#!/usr/bin/python
#
# pingpong.py
# Test program for testing the latency of linuxtuples.
# It pingpongs tuples between two clients.
# First start a server, then execute two clients on two machines
# $ ./pingpong.py foo bar
# $ ./pingpong.py bar foo
# My calculations give me roughly 500 pinpongs per second.
# Gigabit or 100Mb makes little difference. Locally, it is a little faster.
# However, there seems to be a deadlock when doing a 3-way pingpong:
# $ ./pingpong.py tic toe
# $ ./pingpong.py tac tic
# $ ./pingpong.py toe tac
#

import sys
import os
import linuxtuples

if len(sys.argv) != 3 :
  print "Usage:", sys.argv[0], "have want"
  sys.exit(1)

#conn = linuxtuples.connect("rdr01", 7475)
conn = linuxtuples.connect()
print conn

counter = 0

have = sys.argv[1]
want = sys.argv[2]

for i in range(1000) :
  conn.put((have, counter))
  rv=conn.get((want, None))
  if not i :
    time0 = os.times()[4]
  print "Got", rv
#  counter = rv[1] + 1
  counter += 1
time1 = os.times()[4]

print "Elapsed:", time1 - time0