Commit 0aff2383 authored by Kirill Smelkov's avatar Kirill Smelkov

X turn example/hello to return real non-small content

I need this to compare speed wrt github.com/jacobsa/fuse which does not
have ready loopback demo.

Out of the box github.com/jacobsa/fuse turned out to be ~ 1.6x slower
than github.com/hanwen/go-fuse.

with github.com/hanwen/go-fuse:

        .../github.com/hanwen/go-fuse/example/benchmark-read-throughput$ md5sum ~/mnt/tmp/file.txt
        f4cbd65f70761c9c5306d9301422af02  /home/kirr/mnt/tmp/file.txt

        .../github.com/hanwen/go-fuse/example/benchmark-read-throughput$ go run readbench.go -bs 128 -limit 30000 ~/mnt/tmp/file.txt
        block size 128 kb: 30000.4 MB in 9.704823906s: 3091.29 MBs/s

with github.com/jacobsa/fuse

        .../github.com/hanwen/go-fuse/example/benchmark-read-throughput$ md5sum ~/mnt/tmp/hello
        f4cbd65f70761c9c5306d9301422af02  /home/kirr/mnt/tmp/hello

        .../github.com/hanwen/go-fuse/example/benchmark-read-throughput$ go run readbench.go -bs 128 -limit 30000 ~/mnt/tmp/hello
        block size 128 kb: 30000.4 MB in 15.701199318s: 1910.71 MBs/s

See also https://github.com/hanwen/go-fuse/issues/192#issuecomment-338198877
parent 291273cb
...@@ -9,6 +9,7 @@ package main ...@@ -9,6 +9,7 @@ package main
import ( import (
"flag" "flag"
"log" "log"
"io/ioutil"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/nodefs"
...@@ -41,6 +42,17 @@ func (me *HelloFs) OpenDir(name string, context *fuse.Context) (c []fuse.DirEntr ...@@ -41,6 +42,17 @@ func (me *HelloFs) OpenDir(name string, context *fuse.Context) (c []fuse.DirEntr
return nil, fuse.ENOENT return nil, fuse.ENOENT
} }
var data []byte
func init() {
var err error
data, err = ioutil.ReadFile("/boot/initrd.img-4.16.0-2-amd64")
if err != nil {
panic(err)
}
}
func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) {
if name != "file.txt" { if name != "file.txt" {
return nil, fuse.ENOENT return nil, fuse.ENOENT
...@@ -48,7 +60,9 @@ func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file ...@@ -48,7 +60,9 @@ func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file
if flags&fuse.O_ANYWRITE != 0 { if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM return nil, fuse.EPERM
} }
return nodefs.NewDataFile([]byte(name)), fuse.OK
return nodefs.NewDataFile(data), fuse.OK
//return nodefs.NewDataFile([]byte(name)), fuse.OK
} }
func main() { func main() {
......
  • mentioned in commit jacobsa-fuse@a3a68a84

    Toggle commit list
  • As of 20200311 go-fuse v2 (v2.0.2-55-gfe141f3) provides even better speed:

    hellofs using fuse/nodefs API (i.e. old v1/nodefs style):

    .../github.com/hanwen/go-fuse/example/benchmark-read-throughput$ go run readbench.go -bs 128 -limit 30000 ~/mnt/tmp/file.txt
    block size 128 kb: 30006.7 MB in 10.605658901s: 2829.31 MBs/s

    hellofs using fs API (i.e. v2 style (*)):

    (neo) (z-dev) (g.env) kirr@deco:~/src/neo/src/github.com/hanwen/go-fuse/example/benchmark-read-throughput$ go run readbench.go -bs 128 -limit 30000 ~/mnt/tmp/file.txt
    block size 128 kb: 30006.7 MB in 5.199423433s: 5771.15 MBs/s

    jacobsa/fuse stays at approx old ~1.8GB/s for both its master (2f654264), and if patched to call handleOp directly instead of in goroutine: jacobsa-fuse@59a13571, jacobsa-fuse@e891cd16.

    (*) patch to benchmark for recent hellofs:

    --- a/example/hello/main.go
    +++ b/example/hello/main.go
    @@ -11,6 +11,7 @@ import (
            "flag"
            "log"
            "syscall"
    +       "io/ioutil"
     
            "github.com/hanwen/go-fuse/v2/fs"
            "github.com/hanwen/go-fuse/v2/fuse"
    @@ -23,7 +24,8 @@ type HelloRoot struct {
     func (r *HelloRoot) OnAdd(ctx context.Context) {
            ch := r.NewPersistentInode(
                    ctx, &fs.MemRegularFile{
    -                       Data: []byte("file.txt"),
    +                       //Data: []byte("file.txt"),
    +                       Data: data,
                            Attr: fuse.Attr{
                                    Mode: 0644,
                            },
    @@ -39,6 +41,16 @@ func (r *HelloRoot) Getattr(ctx context.Context, fh fs.FileHandle, out *fuse.Att
     var _ = (fs.NodeGetattrer)((*HelloRoot)(nil))
     var _ = (fs.NodeOnAdder)((*HelloRoot)(nil))
     
    +var data []byte
    +func init() {
    +       var err error
    +        data, err = ioutil.ReadFile("/boot/initrd.img-4.19.0-8-amd64")
    +        if err != nil {
    +                panic(err)
    +        }
    +}
    +
    +
     func main() {
            debug := flag.Bool("debug", false, "print debug data")
            flag.Parse()
  • hellofs using fs API (i.e. v2 style (*)):

    (neo) (z-dev) (g.env) kirr@deco:~/src/neo/src/github.com/hanwen/go-fuse/example/benchmark-read-throughput$ > go run readbench.go -bs 128 -limit 30000 ~/mnt/tmp/file.txt
    block size 128 kb: 30006.7 MB in 5.199423433s: 5771.15 MBs/s

    This turned to be false alarm because v2 mem-based fs is using FOPEN_KEEP_CACHE: https://github.com/jacobsa/fuse/issues/78#issuecomment-598194070.

  • mentioned in merge request nexedi/wendelin.core!16 (closed)

    Toggle commit list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment