shithub: gefs

Download patch

ref: f96595cc3fe1fba37aa890643211ed67133dc0c7
parent: 3878b725987e7429d21fb916672523ac81edb0ca
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Oct 3 21:01:34 EDT 2023

main: no need to be as conservative with worker counts.

--- a/main.c
+++ b/main.c
@@ -57,17 +57,17 @@
 }
 
 static void
-launch(void (*f)(int, void *), int wid, void *arg, char *text)
+launch(void (*f)(int, void *), void *arg, char *text)
 {
 	int pid;
 
-	assert(wid == -1 || wid < nelem(fs->lepoch));
+	assert(fs->nworker < nelem(fs->lepoch));
 	pid = rfork(RFPROC|RFMEM|RFNOWAIT);
 	if (pid < 0)
 		sysfatal("can't fork: %r");
 	if (pid == 0) {
 		procsetname("%s", text);
-		(*f)(wid, arg);
+		(*f)(fs->nworker++, arg);
 		exits("child returned");
 	}
 }
@@ -117,7 +117,7 @@
 			continue;
 		}
 
-		launch(runfs, -1, c, "netio");
+		launch(runfs, c, "netio");
 	}
 	close(actl);
 }
@@ -240,24 +240,24 @@
 		fs->arenas[i].sync = &fs->syncq[i%fs->nsyncers];
 	srvfd = postfd(srvname, "");
 	ctlfd = postfd(srvname, ".cmd");
-	launch(runcons, fs->nworker++, (void*)ctlfd, "ctl");
-	launch(runwrite, fs->nworker++, nil, "mutate");
-	launch(runtasks, -1, nil, "tasks");
+	launch(runcons, (void*)ctlfd, "ctl");
+	launch(runwrite, nil, "mutate");
+	launch(runtasks, nil, "tasks");
 	for(i = 0; i < fs->nreaders; i++)
-		launch(runread, fs->nworker++, fs->rdchan[i], "readio");
+		launch(runread, fs->rdchan[i], "readio");
 	for(i = 0; i < fs->nsyncers; i++)
-		launch(runsync, -1, &fs->syncq[i], "syncio");
+		launch(runsync, &fs->syncq[i], "syncio");
 	for(i = 0; i < nann; i++)
-		launch(runannounce, -1, ann[i], "announce");
+		launch(runannounce, ann[i], "announce");
 	if(srvfd != -1){
 		if((c = newconn(srvfd, srvfd)) == nil)
 			sysfatal("%r");
-		launch(runfs, -1, c, "srvio");
+		launch(runfs, c, "srvio");
 	}
 	if(stdio){
 		if((c = newconn(0, 1)) == nil)
 			sysfatal("%r");
-		launch(runfs, -1, c, "stdio");
+		launch(runfs, c, "stdio");
 	}
 	exits(nil);
 }