/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */

#include "config.h"
#include "tapthrottle.hh"

const size_t MINIMUM_SPACE(1024 * 1024);
const size_t MAXIMUM_QUEUE(100000);

bool TapThrottle::persistenceQueueSmallEnough() const {
    size_t queueSize = stats.queue_size.get() + stats.flusher_todo.get();
    return queueSize < MAXIMUM_QUEUE;
}

bool TapThrottle::hasSomeMemory() const {
    size_t currentSize = stats.currentSize.get() + stats.memOverhead.get();
    size_t maxSize = stats.maxDataSize.get();

    return currentSize < maxSize && (maxSize - currentSize) > MINIMUM_SPACE;
}

bool TapThrottle::shouldProcess() const {
    return persistenceQueueSmallEnough() && hasSomeMemory();
}

/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */

#include "config.h"
#include "tapthrottle.hh"

const size_t MINIMUM_SPACE(1024 * 1024);
const size_t MAXIMUM_QUEUE(500000);

bool TapThrottle::persistenceQueueSmallEnough() const {
    size_t queueSize = stats.queue_size.get() + stats.flusher_todo.get();
    return queueSize < MAXIMUM_QUEUE;
}

bool TapThrottle::hasSomeMemory() const {
    size_t currentSize = stats.currentSize.get() + stats.memOverhead.get();
    size_t maxSize = stats.maxDataSize.get();

    return currentSize < maxSize && (maxSize - currentSize) > MINIMUM_SPACE;
}

bool TapThrottle::shouldProcess() const {
    return persistenceQueueSmallEnough() && hasSomeMemory();
}

Adjust tap throttle max persistence queue size up to 500k
Adjust tap throttle max persistence queue size up to 500k

Change-Id: I0e38be6bc984a47f3c8157a39ad2c10a886b6e33
Reviewed-on: http://review.membase.org/3867
Tested-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>
Reviewed-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>
