diff --git a/src/rateLimiter.c b/src/rateLimiter.c index 046ce63..679a62c 100644 --- a/src/rateLimiter.c +++ b/src/rateLimiter.c @@ -8,12 +8,12 @@ #include "rateLimiter.h" #include "utils/min.h" -//How many bytes we can write to disk per second: 30 MB/s +//How many bytes we can write to disk per second: 30 MB/s. Use 0 to specify no limit #define DISK_SPEED 30UL * 1024UL * 1024UL /** If we are not writing to disk, how many seconds the capacity can keep increasing before it reaches the limit. * Increasing this value can result in a spike of data once we are writing to disk again, but then allows the data * to quickly be written without having to wait for capacity to be available. */ -#define MAX_IDLE_TIME 5UL +#define MAX_IDLE_TIME 3UL //Capacity can be filled up to this maximum amount #define CAPACITY_MAX DISK_SPEED * MAX_IDLE_TIME @@ -39,6 +39,11 @@ void increaseCapacity() { /** Pauses execution until the given amount of capacity is available */ void consumeCapacity(unsigned long numBytes) { + //Exit early if there is no capacity limit + if (CAPACITY_MAX == 0UL) { + return; + } + if (numBytes > CAPACITY_MAX) { fprintf(stderr, "Could not consume %lu bytes in rate limiter; maximum is %lu.\n", numBytes, CAPACITY_MAX); errorAndExit();