* [9front] git: cache size in bytes
@ 2021-12-30 2:06 ori
0 siblings, 0 replies; only message in thread
From: ori @ 2021-12-30 2:06 UTC (permalink / raw)
To: 9front
I was looking at syzkaller recently,
and cloning it made git9 unhappy. This
is because our cache size is in object
counts, rather than bytes -- so lots
of large objects can blow away our size.
This change makes git9 track cache sizes
in bytes, which prevents a lot of large
objects from blowing away our memory.
It defaults to 512 MiB, but I'm happy to
tweak that.
diff facb0e757ac63f763bd942a2714f979538b99eb0 uncommitted
--- a/sys/src/cmd/git/git.h
+++ b/sys/src/cmd/git/git.h
@@ -4,6 +4,7 @@
#include <flate.h>
#include <regexp.h>
+typedef struct Capset Capset;
typedef struct Conn Conn;
typedef struct Hash Hash;
typedef struct Delta Delta;
@@ -26,6 +27,9 @@
Npackcache = 32,
Hashsz = 20,
Pktmax = 65536,
+ KiB = 1024,
+ MiB = 1024*KiB,
+ GiB = 1024*MiB,
};
enum {
--- a/sys/src/cmd/git/pack.c
+++ b/sys/src/cmd/git/pack.c
@@ -66,7 +66,7 @@
Object *lruhead;
Object *lrutail;
int ncache;
-int cachemax = 4096;
+int cachemax = 512*MiB;
Packf *packf;
int npackf;
int openpacks;
@@ -158,7 +158,7 @@
if(!(o->flag & Ccache)){
o->flag |= Ccache;
ref(o);
- ncache++;
+ ncache += o->size;
}
while(ncache > cachemax && lrutail != nil){
p = lrutail;
@@ -168,8 +168,8 @@
p->flag &= ~Ccache;
p->prev = nil;
p->next = nil;
+ ncache -= p->size;
unref(p);
- ncache--;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-30 10:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30 2:06 [9front] git: cache size in bytes ori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).