ebin123456 / py-amqplib

Automatically exported from code.google.com/p/py-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Merge patch #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have clone the repo with a fix to speeding up the breaking up of the body.

patch: 
http://code.google.com/r/vbabiy-packing-speed/source/detail?r=39cb634d935395964a
8282b649cb52f855aec59d#

Explain:

# Before patch
from amqplib import client_0_8 as amqp
import time

conn = amqp.connection.Connection()
chan = conn.channel()
msg = amqp.Message("1"*(1048576*100))
s = time.time(); chan.basic_publish(msg); print time.time() - s
54.5186219215

# After Patch
from amqplib import client_0_8 as amqp
import time

conn = amqp.connection.Connection()
chan = conn.channel()
msg = amqp.Message("1"*(1048576*100))
s = time.time(); chan.basic_publish(msg); print time.time() - s
0.23295211792

Original issue reported on code.google.com by vba...@agoragames.com on 28 Oct 2010 at 8:26

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I can't vote for this issue enough.  This patch is basically essential for 
large messages, we were dealing with waiting for minutes to push 100M-500M 
messages into Celery and after the patch it took less than a second.  Please 
apply it!

Original comment by cer...@gmail.com on 26 Mar 2011 at 2:30

GoogleCodeExporter commented 9 years ago
Nice, that is a huge improvement.  

I think the big difference in speed is not due to the generator so much as it 
is in using xrange to pull out just the slices we want to write, and not 
replacing the body over and over and over with the remaining data.  That could 
be done right within the write_method and avoiding the generator call.

I ran some tests on my machine and get results just a tiny tiny hair faster 
than with the original patch.  

Original comment by barry.pe...@gmail.com on 28 Mar 2011 at 5:17