Drastically reduce memory consumption of PPMD8 in adaptive mode (Use lower max model order).

This commit is contained in:
Moinak Ghosh 2013-12-21 20:42:38 +05:30
parent 5521955a94
commit 271414535e
2 changed files with 12 additions and 0 deletions

View file

@ -164,6 +164,7 @@ adapt2_init(void **data, int *level, int nthreads, uint64_t chunksize,
adat->ppmd_data = NULL;
adat->bsc_data = NULL;
lv = *level;
if (lv > 10) lv = 10;
rv = ppmd_init(&(adat->ppmd_data), &lv, nthreads, chunksize, file_version, op);
lv = *level;
if (rv == 0)

View file

@ -30,6 +30,7 @@
#include <pcompress.h>
#include <allocator.h>
#include <Ppmd8.h>
#include <pthread.h>
/*
* PPMd model order to working set memory size mappings.
@ -52,6 +53,9 @@ static unsigned int ppmd8_mem_sz[] = {
(1200 << 20)
};
static pthread_mutex_t mem_init_lock = PTHREAD_MUTEX_INITIALIZER;
static int mem_inited = 0;
static ISzAlloc g_Alloc = {
slab_alloc,
slab_free,
@ -75,6 +79,13 @@ ppmd_init(void **data, int *level, int nthreads, uint64_t chunksize,
{
CPpmd8 *_ppmd;
pthread_mutex_lock(&mem_init_lock);
if (!mem_inited) {
slab_cache_add(sizeof (CPpmd8));
slab_cache_add(ppmd8_mem_sz[*level]);
mem_inited = 1;
}
pthread_mutex_unlock(&mem_init_lock);
_ppmd = (CPpmd8 *)slab_alloc(NULL, sizeof (CPpmd8));
if (!_ppmd)
return (-1);