forked from juicedata/go-fuse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuse: increase max readers for better throughput
Previously maximum number of requests readers was hard-coded to 2. Setting it to max(2, min(16, GOMAXPROCS)) improves the throughput on systems with more cores available. Going beyond 16 readers seems to hurt performance even if there are more cores available. Benchmark GoFuseRead can be used for demonstrating the effects of this variable. The benchmark reads 32 streams in parallel from a dummy filesystem (read operations immediately return zeros). Example results from an i7-8550U (8 cores): | Max readers | Total throughput | | ----------: | ---------------: | | 2 | 13217 MB/s | | 4 | 19202 MB/s | | 8 | 19973 MB/s | | 16 | 18994 MB/s | On a 96 core system: | Max readers | Total throughput | | ----------: | ---------------: | | 2 | 11490 MB/s | | 4 | 16129 MB/s | | 8 | 24263 MB/s | | 16 | 29568 MB/s | | 32 | 28262 MB/s | Note that improvements won't be as dramatic for real filesytem implementations. In benchmarks for a filesystem doing real work I see a 30-40% improvement (8.3 -> 11.4 GB/s) on the 96 core system. Also tweaked some of the other benchmarks so they don't leave behind mountpoints. Fixes hanwen#388. Change-Id: Ibff17d7fc92195f078a9ccff818a31f3a58873f2
- Loading branch information
Showing
7 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ Patrick Crosby <[email protected]> | |
Paul Jolly <[email protected]> | ||
Paul Warren <[email protected]> | ||
Shayan Pooya <[email protected]> | ||
Tommy Lindgren <[email protected]> | ||
Valient Gough <[email protected]> | ||
Yongwoo Park <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021 the Go-FUSE Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package benchmark | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/hanwen/go-fuse/v2/internal/testutil" | ||
"golang.org/x/sync/errgroup" | ||
) | ||
|
||
func BenchmarkGoFuseRead(b *testing.B) { | ||
fs := &readFS{} | ||
wd, clean := setupFs(fs, b.N) | ||
defer clean() | ||
|
||
jobs := 32 | ||
blockSize := 64 * 1024 | ||
|
||
cmds := make([]*exec.Cmd, jobs) | ||
|
||
for i := 0; i < jobs; i++ { | ||
cmds[i] = exec.Command("dd", | ||
fmt.Sprintf("if=%s/foo.txt", wd), | ||
"iflag=direct", | ||
"of=/dev/null", | ||
fmt.Sprintf("bs=%d", blockSize), | ||
fmt.Sprintf("count=%d", b.N)) | ||
if testutil.VerboseTest() { | ||
cmds[i].Stdout = os.Stdout | ||
cmds[i].Stderr = os.Stderr | ||
} | ||
} | ||
|
||
b.SetBytes(int64(jobs * blockSize)) | ||
b.ReportAllocs() | ||
b.ResetTimer() | ||
|
||
var eg errgroup.Group | ||
|
||
for i := 0; i < jobs; i++ { | ||
i := i | ||
eg.Go(func() error { | ||
return cmds[i].Run() | ||
}) | ||
} | ||
|
||
if err := eg.Wait(); err != nil { | ||
b.Fatalf("dd failed: %v", err) | ||
} | ||
|
||
b.StopTimer() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2021 the Go-FUSE Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package benchmark | ||
|
||
import ( | ||
"context" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/hanwen/go-fuse/v2/fs" | ||
"github.com/hanwen/go-fuse/v2/fuse" | ||
) | ||
|
||
const fileSize = 2 << 60 | ||
|
||
// readFS is a filesystem that always and immediately returns zeros on read | ||
// operations. Useful when benchmarking the raw throughput with go-fuse. | ||
type readFS struct { | ||
fs.Inode | ||
} | ||
|
||
var _ = (fs.NodeLookuper)((*readFS)(nil)) | ||
|
||
func (n *readFS) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) { | ||
sattr := fs.StableAttr{Mode: fuse.S_IFREG} | ||
return n.NewInode(ctx, &readFS{}, sattr), fs.OK | ||
} | ||
|
||
var _ = (fs.NodeGetattrer)((*readFS)(nil)) | ||
|
||
func (n *readFS) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno { | ||
out.Size = fileSize | ||
out.SetTimeout(time.Hour) | ||
return fs.OK | ||
} | ||
|
||
var _ = (fs.NodeOpener)((*readFS)(nil)) | ||
|
||
func (n *readFS) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) { | ||
return &readFS{}, fuse.FOPEN_DIRECT_IO, fs.OK | ||
} | ||
|
||
var _ = (fs.FileReader)((*readFS)(nil)) | ||
|
||
func (n *readFS) Read(ctx context.Context, dest []byte, offset int64) (fuse.ReadResult, syscall.Errno) { | ||
return fuse.ReadResultData(dest), fs.OK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters