static size_t g_streamedSize = 0;
static unsigned g_useProgressBar = 0;
static UTIL_freq_t g_ticksPerSecond;
+static unsigned g_forceCompressionLevel = 0;
typedef struct {
void* start;
*/
static unsigned adaptCompressionLevel(adaptCCtx* ctx)
{
- unsigned reset = 0;
- unsigned const allSlow = ctx->adaptParam < ctx->stats.compressedCounter && ctx->adaptParam < ctx->stats.writeCounter && ctx->adaptParam < ctx->stats.readyCounter;
- unsigned const compressWaiting = ctx->adaptParam < ctx->stats.readyCounter;
- unsigned const writeWaiting = ctx->adaptParam < ctx->stats.compressedCounter;
- unsigned const createWaiting = ctx->adaptParam < ctx->stats.writeCounter;
- unsigned const writeSlow = ((compressWaiting && createWaiting) || (createWaiting && !writeWaiting));
- unsigned const compressSlow = ((writeWaiting && createWaiting) || (writeWaiting && !compressWaiting));
- unsigned const createSlow = ((compressWaiting && writeWaiting) || (compressWaiting && !createWaiting));
- DEBUG(3, "ready: %u compressed: %u write: %u\n", ctx->stats.readyCounter, ctx->stats.compressedCounter, ctx->stats.writeCounter);
- if (allSlow) {
- reset = 1;
+ if (g_forceCompressionLevel) {
+ return g_compressionLevel;
}
- else if ((writeSlow || createSlow) && ctx->compressionLevel < (unsigned)ZSTD_maxCLevel()) {
- DEBUG(3, "increasing compression level %u\n", ctx->compressionLevel);
- ctx->compressionLevel++;
- reset = 1;
- }
- else if (compressSlow && ctx->compressionLevel > 1) {
- DEBUG(3, "decreasing compression level %u\n", ctx->compressionLevel);
- ctx->compressionLevel--;
- reset = 1;
- }
- if (reset) {
- ctx->stats.readyCounter = 0;
- ctx->stats.writeCounter = 0;
- ctx->stats.compressedCounter = 0;
+ else {
+ unsigned reset = 0;
+ unsigned const allSlow = ctx->adaptParam < ctx->stats.compressedCounter && ctx->adaptParam < ctx->stats.writeCounter && ctx->adaptParam < ctx->stats.readyCounter;
+ unsigned const compressWaiting = ctx->adaptParam < ctx->stats.readyCounter;
+ unsigned const writeWaiting = ctx->adaptParam < ctx->stats.compressedCounter;
+ unsigned const createWaiting = ctx->adaptParam < ctx->stats.writeCounter;
+ unsigned const writeSlow = ((compressWaiting && createWaiting) || (createWaiting && !writeWaiting));
+ unsigned const compressSlow = ((writeWaiting && createWaiting) || (writeWaiting && !compressWaiting));
+ unsigned const createSlow = ((compressWaiting && writeWaiting) || (compressWaiting && !createWaiting));
+ DEBUG(3, "ready: %u compressed: %u write: %u\n", ctx->stats.readyCounter, ctx->stats.compressedCounter, ctx->stats.writeCounter);
+ if (allSlow) {
+ reset = 1;
+ }
+ else if ((writeSlow || createSlow) && ctx->compressionLevel < (unsigned)ZSTD_maxCLevel()) {
+ DEBUG(3, "increasing compression level %u\n", ctx->compressionLevel);
+ ctx->compressionLevel++;
+ reset = 1;
+ }
+ else if (compressSlow && ctx->compressionLevel > 1) {
+ DEBUG(3, "decreasing compression level %u\n", ctx->compressionLevel);
+ ctx->compressionLevel--;
+ reset = 1;
+ }
+ if (reset) {
+ ctx->stats.readyCounter = 0;
+ ctx->stats.writeCounter = 0;
+ ctx->stats.compressedCounter = 0;
+ }
+ return ctx->compressionLevel;
}
- return ctx->compressionLevel;
}
static size_t getUseableDictSize(unsigned compressionLevel)
forceStdout = 1;
outFilename = stdoutmark;
break;
+ case 'f':
+ g_forceCompressionLevel = 1;
+ break;
default:
DISPLAY("Error: invalid argument provided\n");
ret = 1;
-echo "testing time"
+echo "testing time -- no limits set"
./datagen -g1GB > tmp
time ./adapt -otmp1.zst tmp
time zstd -1 -o tmp2.zst tmp
time zstd -1 -o tmp2.zst tmp
rm tmp*
-echo -e "\ntesting compression ratio"
+echo -e "\ntesting compression ratio -- no limits set"
./datagen -g1GB > tmp
time ./adapt -otmp1.zst tmp
time zstd -1 -o tmp2.zst tmp
time zstd -1 -o tmp2.zst tmp
ls -l tmp1.zst tmp2.zst
rm tmp*
+
+echo e "\ntesting performance at various compression levels -- no limits set"
+./datagen -g1GB > tmp
+echo "adapt"
+time ./adapt -i5 -f tmp -otmp1.zst
+echo "zstdcli"
+time zstd -5 tmp -o tmp2.zst
+ls -l tmp1.zst tmp2.zst
+rm tmp*
+
+./datagen -g1GB > tmp
+echo "adapt"
+time ./adapt -i10 -f tmp -otmp1.zst
+echo "zstdcli"
+time zstd -10 tmp -o tmp2.zst
+ls -l tmp1.zst tmp2.zst
+rm tmp*
+
+./datagen -g1GB > tmp
+echo "adapt"
+time ./adapt -i15 -f tmp -otmp1.zst
+echo "zstdcli"
+time zstd -15 tmp -o tmp2.zst
+ls -l tmp1.zst tmp2.zst
+rm tmp*