diff options
author | Alan Conway <aconway@apache.org> | 2012-04-23 15:51:46 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2012-04-23 15:51:46 +0000 |
commit | fa2d517b97721670a0c5bd55276b346e242288ba (patch) | |
tree | b80174ae0abc7edf88c1f764d11918ae1a5e2107 /qpid/cpp/src/qpid/broker/Fairshare.h | |
parent | a7c7e18f5d000b1e6e211a97e725b8bdca2900cc (diff) | |
download | qpid-python-fa2d517b97721670a0c5bd55276b346e242288ba.tar.gz |
QPID-3960: Fix performance regression in priority queue implementation.
Revision r1307582 created a serious degredation in priority queue performance.
It replaced a muti-deque implementation with o(1) complexity for consuming with
a map implementation with o(log(n)) performance.
This revision returns to a mutli-deque algorithm but with the addition
of a FIFO index for fast browsing of acquired and unacquired messages.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1329301 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/broker/Fairshare.h')
-rw-r--r-- | qpid/cpp/src/qpid/broker/Fairshare.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/qpid/cpp/src/qpid/broker/Fairshare.h b/qpid/cpp/src/qpid/broker/Fairshare.h index dfcbdf280e..1b25721e0c 100644 --- a/qpid/cpp/src/qpid/broker/Fairshare.h +++ b/qpid/cpp/src/qpid/broker/Fairshare.h @@ -22,7 +22,6 @@ * */ #include "qpid/broker/PriorityQueue.h" -#include <vector> namespace qpid { namespace framing { @@ -39,19 +38,23 @@ class Fairshare : public PriorityQueue { public: Fairshare(size_t levels, uint limit); - bool getState(qpid::framing::FieldTable& counts) const; - bool setState(const qpid::framing::FieldTable& counts); + bool getState(uint& priority, uint& count) const; + bool setState(uint priority, uint count); void setLimit(size_t level, uint limit); bool isNull(); - bool consume(QueuedMessage&); static std::auto_ptr<Messages> create(const qpid::framing::FieldTable& settings); - static bool getState(const Messages&, qpid::framing::FieldTable& counts); - static bool setState(Messages&, const qpid::framing::FieldTable& counts); + static bool getState(const Messages&, uint& priority, uint& count); + static bool setState(Messages&, uint priority, uint count); private: std::vector<uint> limits; - std::vector<uint> counts; - bool checkLevel(uint level); + uint priority; + uint count; + + uint currentLevel(); + uint nextLevel(); + bool limitReached(); + bool findFrontLevel(uint& p, PriorityLevels&); }; }} // namespace qpid::broker |