Skip to content

Commit

Permalink
fuse: opt into OpenFile-less and OpenDir-less mode
Browse files Browse the repository at this point in the history
This means files in the page cache can be served by the kernel without having to
round-trip into userspace for OpenFile and OpenDir requests.

before:
distri build -pkg=gtk+-2  368,58s user 80,63s system 829% cpu 54,134 total
distri build -pkg=gtk+-2  368,65s user 81,73s system 832% cpu 54,088 total
distri build -pkg=gtk+-2  368,43s user 82,23s system 832% cpu 54,113 total

with OpenDir-less:
distri build -pkg=gtk+-2  367,24s user 82,04s system 828% cpu 54,253 total

with OpenFile-less:
distri build -pkg=gtk+-2  359,90s user 72,55s system 845% cpu 51,161 total
distri build -pkg=gtk+-2  359,90s user 72,55s system 845% cpu 51,161 total
distri build -pkg=gtk+-2  361,42s user 72,55s system 831% cpu 52,205 total

related to #59
  • Loading branch information
stapelberg committed Feb 15, 2020
1 parent 8f1877b commit 6898f0b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
23 changes: 9 additions & 14 deletions cmd/distri/internal/fuse/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func Mount(args []string) (join func(context.Context) error, _ error) {
},
// Opt into caching resolved symlinks in the kernel page cache:
EnableSymlinkCaching: true,
// Opt into returning -ENOSYS on OpenFile and OpenDir:
EnableNoOpenSupport: true,
EnableNoOpendirSupport: true,
//DebugLogger: log.New(os.Stderr, "[debug] ", log.LstdFlags),
})
if err != nil {
Expand Down Expand Up @@ -1066,15 +1069,9 @@ func (fs *fuseFS) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAt
}

func (fs *fuseFS) OpenDir(ctx context.Context, op *fuseops.OpenDirOp) error {
_, _, err := fs.squashfsInode(op.Inode)
if err != nil {
log.Println(err)
return fuse.EIO
}

//log.Printf("OpenDir(op=%+v, image %d, inode %d)", op, image, squashfsInode)
// TODO: open reader
return nil // allow opening any directory
// Instruct the kernel to not send OpenDir requests for performance:
// https://github.com/torvalds/linux/commit/7678ac50615d9c7a491d9861e020e4f5f71b594c
return fuse.ENOSYS
}

/*
Expand Down Expand Up @@ -1201,11 +1198,9 @@ func (fs *fuseFS) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) error {
}

func (fs *fuseFS) OpenFile(ctx context.Context, op *fuseops.OpenFileOp) error {
//log.Printf("OpenFile(op=%+v)", op)

op.KeepPageCache = true // no modifications are happening in immutable images

return nil // allow opening any file
// Instruct the kernel to not send OpenFile requests for performance:
// https://github.com/torvalds/linux/commit/7678ac50615d9c7a491d9861e020e4f5f71b594c
return fuse.ENOSYS
}

func (fs *fuseFS) ReadFile(ctx context.Context, op *fuseops.ReadFileOp) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/google/go-cmp v0.3.0
github.com/google/go-github/v27 v27.0.4
github.com/google/renameio v0.0.0-20181108174601-76365acd908f
github.com/jacobsa/fuse v0.0.0-20200215070453-7c2b5692506e
github.com/jacobsa/fuse v0.0.0-20200215073154-2f65426467b1
github.com/klauspost/compress v1.9.7 // indirect
github.com/klauspost/pgzip v1.2.1
github.com/lpar/gzipped v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASu
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/renameio v0.0.0-20181108174601-76365acd908f h1:lhDFIjvRqIJDmEHDSeRSiWee4a0oDr0vPpvdFviPcEo=
github.com/google/renameio v0.0.0-20181108174601-76365acd908f/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/jacobsa/fuse v0.0.0-20200215070453-7c2b5692506e h1:YNGCeJgVJyy55Ax1X9nQFehX3x4s8jgh6xvL22zsAWU=
github.com/jacobsa/fuse v0.0.0-20200215070453-7c2b5692506e/go.mod h1:9Aml1MG17JVeXrN4D2mtJvYHtHklJH5bESjCKNzVjFU=
github.com/jacobsa/fuse v0.0.0-20200215073154-2f65426467b1 h1:MG5fuylvlDJtIZGQav3R4d4rKCs9wSRDkZmDARuLbCg=
github.com/jacobsa/fuse v0.0.0-20200215073154-2f65426467b1/go.mod h1:9Aml1MG17JVeXrN4D2mtJvYHtHklJH5bESjCKNzVjFU=
github.com/klauspost/compress v1.9.7 h1:hYW1gP94JUmAhBtJ+LNz5My+gBobDxPR1iVuKug26aA=
github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM=
Expand Down
6 changes: 3 additions & 3 deletions pkgs/go-github.com-jacobsa-fuse/build.textproto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source: "distri+gomod://github.com/jacobsa/[email protected]20200215070453-7c2b5692506e"
hash: "6222d125a9bdcd28b37d55d8e88e63d011270be4b4d600f882b2138b0e76ada5"
version: "v0.0.0-20200215070453-7c2b5692506e-5"
source: "distri+gomod://github.com/jacobsa/[email protected]20200215073154-2f65426467b1"
hash: "09d4f926e458201cd6815c287979c457855200c0c84f66af55dc733cc06c6b61"
version: "v0.0.0-20200215073154-2f65426467b1-6"

gomodbuilder: {}

Expand Down

0 comments on commit 6898f0b

Please sign in to comment.