2

I am running the following program:

import cStringIO
import time
import threading

def func(tid):
    buff = 'a'*4096
    i = 0
    while (i < 40000000):
        output = cStringIO.StringIO()
        output.write(buff)
        contents = output.getvalue()
        output.close()
        i = i + 1

threads = 16
threadlist = []

start = time.time()
for tc in range(threads):
    thr = threading.Thread(target=func, args=(tc,))
    threadlist.append(thr)
    thr.start()

for thr in threadlist:
    thr.join()

end = time.time()
print "Time taken is %s" % (end - start)

on machines with exact same hardware however one running ubuntu 10.04 and the other running 14.04. I observe that it takes 1409.54 sec on 10.04 whereas it takes 1656.81 sec on 14.04 showing 17% performance degradation on 14.04. Any ideas?

  • Did you try converting to python3? Major performance improvements have been made to python3 in the meanwhile. The other point is, did you check the python versions on each system? – Oliver Friedrich Sep 07 '15 at 08:38
  • @BeowulfOF python3 is not a choice mostly due to limited package support it offers at this time. I have installed and using the same python version, namely 2.7.8, on both the machines. – Sameer Mahajan Sep 07 '15 at 08:40
  • I would suggest profiling the program again using the [`timeit`](https://docs.python.org/2/library/timeit.html) module. Just as a comparison. – Steven Correia Sep 07 '15 at 09:02

1 Answers1

0

This behavior was due to hyperthreading on 14.04. Interestingly after disabling hyper thread on my 2 core machine (and effectively running on a single hyper thread), 14.04 gave performance that was at par with that of 10.04.