postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 357 forks source link

Fix bottleneck when using confirms #266

Closed aheckmann closed 10 years ago

aheckmann commented 10 years ago

Publishing msgs using confirms can create a situation where so many event listeners are registered that exchange.removeListener becomes a significant bottleneck (see https://gist.github.com/aheckmann/7762370)

Instead of relying on EventEmitter, this PR now registers a single error handler for the exchange and handle error disbursement manually.

Results of running the above gist as follows:

> time DEBUG=amqp:* COUNT=30000 PREFETCH=0 BUCKET_SIZE=20000 node index.js

before applying the fix:

real  1m22.216s
user  1m10.973s
sys 0m16.106s

after:

real  0m25.034s
user  0m14.082s
sys 0m15.153s

Also tried to make whitespace use more consistent throughout the project base on what seemed to be the predominant style.

aheckmann commented 10 years ago

thanks!