shithub: neoventi

Download patch

ref: b008c03c4d842750bb6635096cfcd7cea8355e79
parent: 3f161da5fe64d5d28623a92c1746ca3ae46ad196
author: Noam Preil <noam@pixelhero.dev>
date: Sat Mar 23 09:29:12 EDT 2024

cache: loop around buckets when probing

--- a/cache.c
+++ b/cache.c
@@ -113,11 +113,15 @@
 	int i;
 	u32int key = (arenaindex << 16) | blockindex;
 	bucket_t *bucket = getbucket(key);
-	while(bucket != bucketend){
+	usize tried = 0;
+	while(tried < BUCKETS){
 		switch(trybucket(bucket, &i, key)){
 		case -1:
 			// miss. linear probe.
+			tried+=1;
 			bucket++;
+			if(bucket == bucketend)
+				bucket = buckets;
 			continue;
 		case 0:
 			// found an empty slot
@@ -131,8 +135,6 @@
 			return 1;
 		}
 	}
-//FIXME not unreachable
-//if the final bucket is full, we must handle it
-	sysfatal("unreachable");
+	sysfatal("TODO: support eviction");
 	return 0;
 }
--