summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-17 21:37:36 +0200
committerJakob Unterwurzacher2020-05-17 21:37:36 +0200
commitf8ad2ac3e252108ccfedd115eb3009a5a7d77106 (patch)
tree66b9ddec7b8a2eddda7e432389ee23ee4abb410b
parentf6088e5008606ba8ca8f7be2b95b5087b59e5cab (diff)
dircache: increase cache size & lifetime
Looking at the dircache debug output, we see that a "git status" workload has a very bad cache hit rate because the entries expire or get evicted before they can be reused. Increase both cache size and lifetime for a 4x speedup: Before: 75s After: 17s https://github.com/rfjakob/gocryptfs/issues/410
-rw-r--r--internal/fusefrontend/dircache.go8
-rw-r--r--tests/test_helpers/mount_unmount.go10
2 files changed, 9 insertions, 9 deletions
diff --git a/internal/fusefrontend/dircache.go b/internal/fusefrontend/dircache.go
index 718e5b2..d6ec52c 100644
--- a/internal/fusefrontend/dircache.go
+++ b/internal/fusefrontend/dircache.go
@@ -12,11 +12,11 @@ import (
)
const (
- // Number of entries in the dirCache. Three entries work well for two
- // (probably also three) parallel tar extracts (hit rate around 92%).
+ // Number of entries in the dirCache.
+ // 20 entries work well for "git stat" on a small git repo on sshfs.
// Keep in sync with test_helpers.maxCacheFds !
// TODO: How to share this constant without causing an import cycle?
- dirCacheSize = 3
+ dirCacheSize = 20
// Enable Lookup/Store/Clear debug messages
enableDebugMessages = false
// Enable hit rate statistics printing
@@ -151,7 +151,7 @@ func (d *dirCacheStruct) Lookup(dirRelPath string) (fd int, iv []byte) {
// expireThread is started on the first Lookup()
func (d *dirCacheStruct) expireThread() {
for {
- time.Sleep(1 * time.Second)
+ time.Sleep(60 * time.Second)
d.Clear()
if enableStats {
d.Lock()
diff --git a/tests/test_helpers/mount_unmount.go b/tests/test_helpers/mount_unmount.go
index cdbdee8..76db41c 100644
--- a/tests/test_helpers/mount_unmount.go
+++ b/tests/test_helpers/mount_unmount.go
@@ -14,6 +14,11 @@ import (
"time"
)
+// gocryptfs may hold up to maxCacheFds open for caching
+// Keep in sync with fusefrontend.dirCacheSize
+// TODO: How to share this constant without causing an import cycle?!
+const maxCacheFds = 20
+
// Indexed by mountpoint. Initialized in doInit().
var MountInfo map[string]mountInfo
@@ -137,11 +142,6 @@ func UnmountPanic(dir string) {
}
}
-// gocryptfs may hold up to maxCacheFds open for caching
-// Keep in sync with fusefrontend.dirCacheSize
-// TODO: How to share this constant without causing an import cycle?!
-const maxCacheFds = 3
-
// UnmountErr tries to unmount "dir", retrying 10 times, and returns the
// resulting error.
func UnmountErr(dir string) (err error) {