mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add FUSE dimension to gvisor macrobenchmarks.
PiperOrigin-RevId: 534131305
This commit is contained in:
committed by
gVisor bot
parent
7e32a23838
commit
a933719841
@@ -22,6 +22,7 @@ benchmark_test(
|
|||||||
benchmark_test(
|
benchmark_test(
|
||||||
name = "fio_test",
|
name = "fio_test",
|
||||||
srcs = ["fio_test.go"],
|
srcs = ["fio_test.go"],
|
||||||
|
data = ["//test/runner/fuse"],
|
||||||
visibility = ["//:sandbox"],
|
visibility = ["//:sandbox"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/cleanup",
|
"//pkg/cleanup",
|
||||||
|
|||||||
@@ -114,12 +114,13 @@ func BenchmarkFio(b *testing.B) {
|
|||||||
b.Fatalf("failed to make mount: %v", err)
|
b.Fatalf("failed to make mount: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runOpts := dockerutil.RunOpts{
|
||||||
|
Image: "benchmarks/fio",
|
||||||
|
Mounts: mnts,
|
||||||
|
}
|
||||||
// Start the container with the mount.
|
// Start the container with the mount.
|
||||||
if err := container.Spawn(
|
if err := container.Spawn(
|
||||||
ctx, dockerutil.RunOpts{
|
ctx, runOpts,
|
||||||
Image: "benchmarks/fio",
|
|
||||||
Mounts: mnts,
|
|
||||||
},
|
|
||||||
// Sleep on the order of b.N.
|
// Sleep on the order of b.N.
|
||||||
"sleep", fmt.Sprintf("%d", 1000*b.N),
|
"sleep", fmt.Sprintf("%d", 1000*b.N),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
@@ -131,6 +132,16 @@ func BenchmarkFio(b *testing.B) {
|
|||||||
b.Fatalf("failed to copy directory: %v (%s)", err, out)
|
b.Fatalf("failed to copy directory: %v (%s)", err, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fsType == harness.FuseFS {
|
||||||
|
container.CopyFiles(&runOpts, "/fusebin", "test/runner/fuse/fuse")
|
||||||
|
_, err := container.ExecProcess(ctx, dockerutil.ExecOpts{
|
||||||
|
Privileged: true,
|
||||||
|
}, "/fusebin/fuse", "--dir="+outdir, "--debug=false")
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("starting fuse server failed with: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Directory and filename inside container where fio will read/write.
|
// Directory and filename inside container where fio will read/write.
|
||||||
outfile := filepath.Join(outdir, "test.txt")
|
outfile := filepath.Join(outdir, "test.txt")
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ go_library(
|
|||||||
name = "fsbench",
|
name = "fsbench",
|
||||||
testonly = 1,
|
testonly = 1,
|
||||||
srcs = ["fsbench.go"],
|
srcs = ["fsbench.go"],
|
||||||
|
data = ["//test/runner/fuse"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/cleanup",
|
"//pkg/cleanup",
|
||||||
"//pkg/test/dockerutil",
|
"//pkg/test/dockerutil",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ type FSBenchmark struct {
|
|||||||
WantOutput string
|
WantOutput string
|
||||||
// CleanCmd, if set, is run to clean up between benchmarks.
|
// CleanCmd, if set, is run to clean up between benchmarks.
|
||||||
CleanCmd []string
|
CleanCmd []string
|
||||||
// Variants is a list of benchmarka variants to run.
|
// Variants is a list of benchmark variants to run.
|
||||||
// If unset, the typical set is used.
|
// If unset, the typical set is used.
|
||||||
Variants []Variant
|
Variants []Variant
|
||||||
// Callback is an optional function that is called after each execution of
|
// Callback is an optional function that is called after each execution of
|
||||||
@@ -63,8 +63,8 @@ type Variant struct {
|
|||||||
|
|
||||||
// TypicalVariants returns the typical full set of benchmark variants.
|
// TypicalVariants returns the typical full set of benchmark variants.
|
||||||
func TypicalVariants() []Variant {
|
func TypicalVariants() []Variant {
|
||||||
variants := make([]Variant, 0, 6)
|
variants := make([]Variant, 0, 8)
|
||||||
for _, filesys := range []harness.FileSystemType{harness.BindFS, harness.TmpFS, harness.RootFS} {
|
for _, filesys := range []harness.FileSystemType{harness.FuseFS} {
|
||||||
variants = append(variants, Variant{
|
variants = append(variants, Variant{
|
||||||
clearCache: true,
|
clearCache: true,
|
||||||
fsType: filesys,
|
fsType: filesys,
|
||||||
@@ -125,7 +125,24 @@ func RunWithDifferentFilesystems(ctx context.Context, b *testing.B, machine harn
|
|||||||
b.Fatalf("run failed with: %v", err)
|
b.Fatalf("run failed with: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cpCmd := fmt.Sprintf("mkdir -p %s && cp -r %s %s/.", prefix, bm.WorkDir, prefix)
|
// Ignore safetext/shsprintf linter suggestion.
|
||||||
|
mkdirCmd := fmt.Sprintf("mkdir -p %s", prefix)
|
||||||
|
out, err := container.Exec(ctx, dockerutil.ExecOpts{}, "/bin/sh", "-c", mkdirCmd)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to make directory: %v (%s)", err, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
if variant.fsType == harness.FuseFS {
|
||||||
|
container.CopyFiles(&runOpts, "/fusebin", "test/runner/fuse/fuse")
|
||||||
|
_, err := container.ExecProcess(ctx, dockerutil.ExecOpts{
|
||||||
|
Privileged: true,
|
||||||
|
}, "/fusebin/fuse", "--dir="+prefix, "--debug=false")
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("starting fuse server failed with: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cpCmd := fmt.Sprintf("cp -r %s %s/.", bm.WorkDir, prefix)
|
||||||
if out, err := container.Exec(ctx, dockerutil.ExecOpts{},
|
if out, err := container.Exec(ctx, dockerutil.ExecOpts{},
|
||||||
"/bin/sh", "-c", cpCmd); err != nil {
|
"/bin/sh", "-c", cpCmd); err != nil {
|
||||||
b.Fatalf("failed to copy directory: %v (%s)", err, out)
|
b.Fatalf("failed to copy directory: %v (%s)", err, out)
|
||||||
|
|||||||
@@ -69,13 +69,15 @@ const (
|
|||||||
TmpFS FileSystemType = "tmpfs"
|
TmpFS FileSystemType = "tmpfs"
|
||||||
// RootFS indicates no mount should be created and the root mount should be used.
|
// RootFS indicates no mount should be created and the root mount should be used.
|
||||||
RootFS FileSystemType = "rootfs"
|
RootFS FileSystemType = "rootfs"
|
||||||
|
// FuseFS indicates a passthrough fuse server should be created.
|
||||||
|
FuseFS FileSystemType = "fusefs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MakeMount makes a mount and cleanup based on the requested type. Bind
|
// MakeMount makes a mount and cleanup based on the requested type. Bind
|
||||||
// and volume mounts are backed by a temp directory made with mktemp.
|
// and volume mounts are backed by a temp directory made with mktemp.
|
||||||
// tmpfs mounts require no such backing and are just made.
|
// tmpfs mounts require no such backing and are just made.
|
||||||
// rootfs mounts do not make a mount, but instead return a target direectory at root.
|
// rootfs mounts do not make a mount, but instead return a target directory at
|
||||||
// It is up to the caller to call Clean on the passed *cleanup.Cleanup
|
// root. It is up to the caller to call Clean on the passed *cleanup.Cleanup.
|
||||||
func MakeMount(machine Machine, fsType FileSystemType, cu *cleanup.Cleanup) ([]mount.Mount, string, error) {
|
func MakeMount(machine Machine, fsType FileSystemType, cu *cleanup.Cleanup) ([]mount.Mount, string, error) {
|
||||||
mounts := make([]mount.Mount, 0, 1)
|
mounts := make([]mount.Mount, 0, 1)
|
||||||
target := "/data"
|
target := "/data"
|
||||||
@@ -107,6 +109,18 @@ func MakeMount(machine Machine, fsType FileSystemType, cu *cleanup.Cleanup) ([]m
|
|||||||
Type: mount.TypeTmpfs,
|
Type: mount.TypeTmpfs,
|
||||||
})
|
})
|
||||||
return mounts, target, nil
|
return mounts, target, nil
|
||||||
|
case FuseFS:
|
||||||
|
mounts = append(mounts, []mount.Mount{
|
||||||
|
{
|
||||||
|
Target: target,
|
||||||
|
Type: mount.TypeTmpfs,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Target: "/fuse",
|
||||||
|
Type: mount.TypeTmpfs,
|
||||||
|
},
|
||||||
|
}...)
|
||||||
|
return mounts, target, nil
|
||||||
default:
|
default:
|
||||||
return mounts, "", fmt.Errorf("illegal mount type not supported: %v", fsType)
|
return mounts, "", fmt.Errorf("illegal mount type not supported: %v", fsType)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ package(
|
|||||||
go_binary(
|
go_binary(
|
||||||
name = "fuse",
|
name = "fuse",
|
||||||
srcs = ["fuse.go"],
|
srcs = ["fuse.go"],
|
||||||
visibility = ["//test/runner:__subpackages__"],
|
visibility = [
|
||||||
|
"//test/benchmarks:__subpackages__",
|
||||||
|
"//test/runner:__subpackages__",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/log",
|
"//pkg/log",
|
||||||
"//runsc/specutils",
|
"//runsc/specutils",
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
opts := &fuse.MountOptions{DirectMountStrict: true, Debug: *debug, AllowOther: true, Options: []string{"default_permissions"}}
|
opts := &fuse.MountOptions{DirectMountStrict: true, Debug: *debug, AllowOther: true, Options: []string{"default_permissions"}}
|
||||||
rawFS := fs.NewNodeFS(loopbackRoot, &fs.Options{NullPermissions: true, Logger: golog.Default()})
|
rawFS := fs.NewNodeFS(loopbackRoot, &fs.Options{NullPermissions: true, Logger: golog.Default()})
|
||||||
server, err := fuse.NewServer(rawFS, "/tmp", opts)
|
server, err := fuse.NewServer(rawFS, *dir, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("could not create fuse server: %v", err)
|
log.Warningf("could not create fuse server: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user