git: 9front

Download patch

ref: 23fdf669555931b8c9c510764cc8e768d9cf6225
parent: afdf03c92dd79b603b5edb47ba592964aae10952
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Dec 2 16:08:52 EST 2023

git/fs: don't unload large objects when inserting into cache

When inserting an object into cache, we try to remove objects
from cache to keep the size below the limit. If the object is
larger than the cache, we try to unload not only every cached
object, but the object we're in the process of inserting.

This leads to an immediate unload of the object, which is very
wrong.

--- a/sys/src/cmd/git/pack.c
+++ b/sys/src/cmd/git/pack.c
@@ -160,7 +160,7 @@
 		ref(o);
 		ncache += o->size;
 	}
-	while(ncache > cachemax && lrutail != nil){
+	while(ncache > cachemax && lrutail != lruhead){
 		p = lrutail;
 		lrutail = p->prev;
 		if(lrutail != nil)
--