diff options
author | mfederico <mfederico@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-16 07:20:44 +0400 |
---|---|---|
committer | mfederico <mfederico@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-16 07:20:44 +0400 |
commit | be6b9d8ce586034c3e0f4df700cdda890805d94f (patch) | |
tree | d3b15cbde6436545dd3ecf08de6d4ff5d68e7d10 /irstlm | |
parent | 0aaf45fd98e036c61c4aa32ec5922f055d4019ad (diff) |
Tuning of cache values
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@766 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'irstlm')
-rw-r--r-- | irstlm/src/lmtable.h | 10 | ||||
-rw-r--r-- | irstlm/src/ngramcache.cpp | 12 | ||||
-rw-r--r-- | irstlm/src/ngramcache.h | 3 |
3 files changed, 15 insertions, 10 deletions
diff --git a/irstlm/src/lmtable.h b/irstlm/src/lmtable.h index 7960c766c..15f7e4fa2 100644 --- a/irstlm/src/lmtable.h +++ b/irstlm/src/lmtable.h @@ -185,7 +185,7 @@ public: void init_probcache(){ assert(probcache==NULL); - probcache=new ngramcache(maxlev,sizeof(double),200000); + probcache=new ngramcache(maxlev,sizeof(double),400000); #ifdef TRACE_CACHE cacheout=new std::fstream("/tmp/tracecache",std::ios::out); sentence_id=0; @@ -194,7 +194,7 @@ public: void init_statecache(){ assert(statecache==NULL); - statecache=new ngramcache(maxlev-1,sizeof(char *),100000); + statecache=new ngramcache(maxlev-1,sizeof(char *),200000); } void init_lmtcaches(int uptolev){ @@ -206,10 +206,10 @@ public: } void check_cache_levels(){ - if (probcache && probcache->isfull()) probcache->reset(); - if (statecache && statecache->isfull()) statecache->reset(); + if (probcache && probcache->isfull()) probcache->reset(probcache->cursize()); + if (statecache && statecache->isfull()) statecache->reset(statecache->cursize()); for (int i=2;i<=max_cache_lev;i++) - if (lmtcache[i]->isfull()) lmtcache[i]->reset(); + if (lmtcache[i]->isfull()) lmtcache[i]->reset(lmtcache[i]->cursize()); } bool is_probcache_active(){return probcache!=NULL;} diff --git a/irstlm/src/ngramcache.cpp b/irstlm/src/ngramcache.cpp index 271be4cf1..3b4234bcc 100644 --- a/irstlm/src/ngramcache.cpp +++ b/irstlm/src/ngramcache.cpp @@ -35,7 +35,7 @@ ngramcache::ngramcache(int n,int size,int maxentries){ maxn=maxentries; entries=0; ht=new htable(maxn * 2, ngsize * sizeof(int),INT,NULL); //lower load factor to reduce collisions - mp=new mempool(ngsize * sizeof(int)+infosize,maxn/5); + mp=new mempool(ngsize * sizeof(int)+infosize,1000000); accesses=0; hits=0; }; @@ -47,15 +47,19 @@ ngramcache::~ngramcache(){ }; -void ngramcache::reset(){ +//resize cache to specified number of entries +void ngramcache::reset(int n){ ht->stat(); - delete ht;delete mp; + delete ht;delete mp; + if (n>0) maxn=n; ht=new htable(maxn * 2, ngsize * sizeof(int),INT,NULL); //load factor 2 - mp=new mempool(ngsize * sizeof(int)+infosize,maxn/5); + mp=new mempool(ngsize * sizeof(int)+infosize,1000000); entries=0; } + + char* ngramcache::get(const int* ngp,char* info){ char *found; // cout << "ngramcache::get() "; diff --git a/irstlm/src/ngramcache.h b/irstlm/src/ngramcache.h index 6f57cc926..d7d98e644 100644 --- a/irstlm/src/ngramcache.h +++ b/irstlm/src/ngramcache.h @@ -37,9 +37,10 @@ private: public: + int cursize(){return entries;}; ngramcache(int n,int size,int maxentries); ~ngramcache(); - void reset(); + void reset(int n=0); char* get(const int* ngp,char* info=NULL); int add(const int* ngp,const char* info); int isfull(){return (entries >= maxn);}; |