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() {
......
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