If there are multiple consumers on a queue, a certain percentage of acknowledgements will not be at the head of the queue because consumers will not act in lock step. Every time a message not at the head of the queue is consumed we increment the scavenge count to indicate that we should scan the queue for deleted entries and remove them. If the queue is very large then this will take a long time. Clearing down a very large queue with multiple consumers will thus become very expensive.
We can reduce the cost of scavenging by keeping a record of the high watermark of deleted entries that weren't at the head of the queue, and only scavenging the queue to a point beyond the high watermark