shithub: gefs

Download patch

ref: 1ba67b57e8e863229f5eb19fceba5f7f7c224cf5
parent: 85cd892f0121f21c30f8b65645729c0097ef1429
author: Ori Bernstein <[email protected]>
date: Fri Nov 3 17:14:37 EDT 2023

blk: move log compression to syncing

let's minimize the amount of time we spend on a swapped
out sync list, and put a barrier in the right place.

--- a/fs.c
+++ b/fs.c
@@ -2205,6 +2205,7 @@
 	vlong off;
 	Amsg *a;
 	Msg m;
+	int i;
 
 	while(1){
 		a = chrecv(fs->admchan);
@@ -2211,6 +2212,16 @@
 		switch(a->op){
 		case AOsync:
 			qlock(&fs->mutlk);
+			for(i = 0; i < fs->narena; i++){
+				epochstart(id);
+				qlock(&fs->arenas[i]);
+				if(fs->arenas[i].nlog > fs->arenas[i].reserve/(10*Blksz))
+					if(compresslog(&fs->arenas[i]) == -1)
+						fprint(2, "compress log: %r");
+				qunlock(&fs->arenas[i]);
+				epochend(id);
+				epochclean();
+			}
 			if(a->halt)
 				ainc(&fs->rdonly);
 			epochstart(id);
@@ -2259,13 +2270,12 @@
 }
 
 void
-runtasks(int id, void *)
+runtasks(int, void *)
 {
-	int i, c;
 	Amsg *a;
 
 	while(1){
-		sleep(5000);
+		sleep(500);
 		a = mallocz(sizeof(Amsg), 1);
 		if(a == nil){
 			fprint(2, "alloc sync msg: %r\n");
@@ -2276,28 +2286,5 @@
 		a->halt = 0;
 		a->fd = -1;
 		chsend(fs->admchan, a);
-
-		/*
-		 * compresslog is designed to be concurrent with allocation,
-		 * so it's safe to call from outside the mutator proc; we
-		 * don't want to spend a ton of time compressing, though,
-		 * so we only do the compression when our log gets big.
-		 *
-		 * 10% of our reserved emergency space seems like a good
-		 * heuristic for big, but it was picked arbitrarily.
-		 */
-		qlock(&fs->synclk);
-		for(i = 0; i < fs->narena; i++){
-			epochstart(id);
-			qlock(&fs->arenas[i]);
-			c = fs->arenas[i].nlog > fs->arenas[i].reserve/(10*Blksz);
-			if(c){
-				if(compresslog(&fs->arenas[i]) == -1)
-					fprint(2, "compress log: %r");
-			}
-			qunlock(&fs->arenas[i]);
-			epochend(id);
-		}
-		qunlock(&fs->synclk);
 	}
 }
--- a/load.c
+++ b/load.c
@@ -112,7 +112,6 @@
 	fprint(2, "\tarenasz:\t%lld MiB\n", fs->arenasz/MiB);
 	fprint(2, "\tnextqid:\t%lld\n", fs->nextqid);
 	fprint(2, "\tnextgen:\t%lld\n", fs->nextgen);
-	fprint(2, "\tsyncgen:\t%lld\n", fs->qgen);
 	fprint(2, "\tblocksize:\t%lld\n", Blksz);
 	fprint(2, "\tcachesz:\t%lld MiB\n", fs->cmax*Blksz/MiB);
 	if((t = opensnap("adm", nil)) == nil)