ref: 201fe8de4bd2597cee9ef94273abce2ddf0a1a58
parent: a19d90dc8c4d48ec613ac3e2e1462b9099c0a857
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Jul 7 23:29:40 EDT 2024
gefs: change log compression heuristic compress when the log doubles in size, rather than using a fixed size heuristic; this means that we don't start compressing frequently as the log gets big and the file system gets fragmented.
--- a/sys/src/cmd/gefs/blk.c
+++ b/sys/src/cmd/gefs/blk.c
@@ -483,6 +483,7 @@
a->loghd = (Bptr){blks[0], -1, -1};
a->logtl = b; /* written back by sync() later */
a->nlog = nlog;
+ a->lastlogsz = nlog;
/* May add blocks to new log */
for(; i < nblks; i++)
--- a/sys/src/cmd/gefs/dat.h
+++ b/sys/src/cmd/gefs/dat.h
@@ -596,6 +596,7 @@
vlong used;
vlong reserve;
/* allocation log */
+ vlong lastlogsz; /* size after last compression */
vlong nlog; /* number of blocks in log */
Bptr loghd; /* allocation log */
Blk *logtl; /* end of the log, open for writing */
--- a/sys/src/cmd/gefs/fs.c
+++ b/sys/src/cmd/gefs/fs.c
@@ -2474,10 +2474,10 @@
oldhd[i] = Zb;
qlock(a);
/*
- * arbitrary heuristic -- 10% of our reserved
- * space seems like a fine time to compress.
+ * arbitrary heuristic -- try compressing
+ * when the log doubles in size.
*/
- if(a->nlog >= a->reserve/(10*Blksz)){
+ if(a->nlog >= 2*a->lastlogsz){
oldhd[i] = a->loghd;
epochstart(id);
if(waserror()){
--
⑨