git: size cache in bytes, not objects
git used to track cache size in object count, rather than bytes. This had the unfortunate effect of making memory use depend on the size of objects -- repos with lots of large objects could cause out of memory deaths. now, we track sizes in bytes, which should keep our memory usage flatter.
This commit is contained in:
parent
99d54e420e
commit
f63d1d3ced
2 changed files with 8 additions and 5 deletions
|
@ -65,8 +65,8 @@ static Object *readidxobject(Biobuf *, Hash, int);
|
|||
Objset objcache;
|
||||
Object *lruhead;
|
||||
Object *lrutail;
|
||||
int ncache;
|
||||
int cachemax = 4096;
|
||||
vlong ncache;
|
||||
vlong cachemax = 512*MiB;
|
||||
Packf *packf;
|
||||
int npackf;
|
||||
int openpacks;
|
||||
|
@ -158,7 +158,7 @@ cache(Object *o)
|
|||
if(!(o->flag & Ccache)){
|
||||
o->flag |= Ccache;
|
||||
ref(o);
|
||||
ncache++;
|
||||
ncache += o->size;
|
||||
}
|
||||
while(ncache > cachemax && lrutail != nil){
|
||||
p = lrutail;
|
||||
|
@ -168,8 +168,8 @@ cache(Object *o)
|
|||
p->flag &= ~Ccache;
|
||||
p->prev = nil;
|
||||
p->next = nil;
|
||||
ncache -= p->size;
|
||||
unref(p);
|
||||
ncache--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue