summaryrefslogtreecommitdiffhomepage
path: root/test/benchmarks/fs
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2021-03-18 12:11:59 -0700
committergVisor bot <gvisor-bot@google.com>2021-03-18 12:14:27 -0700
commit29be908ab69d2d333572f6990d331e494b1e51fd (patch)
treed00c5282c8b8f6dee767ef378a11051ddf78b157 /test/benchmarks/fs
parent5c4f4ed9eb05cfef036b55883edb8de780288441 (diff)
Address post submit comments for fs benchmarks.
Also, drop fio total reads/writes to 1GB as 10GB is prohibitively slow. PiperOrigin-RevId: 363714060
Diffstat (limited to 'test/benchmarks/fs')
-rw-r--r--test/benchmarks/fs/BUILD2
-rw-r--r--test/benchmarks/fs/bazel_test.go23
-rw-r--r--test/benchmarks/fs/fio_test.go20
3 files changed, 29 insertions, 16 deletions
diff --git a/test/benchmarks/fs/BUILD b/test/benchmarks/fs/BUILD
index c94caab60..dc82e63b2 100644
--- a/test/benchmarks/fs/BUILD
+++ b/test/benchmarks/fs/BUILD
@@ -8,6 +8,7 @@ benchmark_test(
srcs = ["bazel_test.go"],
visibility = ["//:sandbox"],
deps = [
+ "//pkg/cleanup",
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
"//test/benchmarks/tools",
@@ -21,6 +22,7 @@ benchmark_test(
srcs = ["fio_test.go"],
visibility = ["//:sandbox"],
deps = [
+ "//pkg/cleanup",
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
"//test/benchmarks/tools",
diff --git a/test/benchmarks/fs/bazel_test.go b/test/benchmarks/fs/bazel_test.go
index 7ced963f6..797b1952d 100644
--- a/test/benchmarks/fs/bazel_test.go
+++ b/test/benchmarks/fs/bazel_test.go
@@ -20,6 +20,7 @@ import (
"strings"
"testing"
+ "gvisor.dev/gvisor/pkg/cleanup"
"gvisor.dev/gvisor/pkg/test/dockerutil"
"gvisor.dev/gvisor/test/benchmarks/harness"
"gvisor.dev/gvisor/test/benchmarks/tools"
@@ -28,8 +29,8 @@ import (
// Dimensions here are clean/dirty cache (do or don't drop caches)
// and if the mount on which we are compiling is a tmpfs/bind mount.
type benchmark struct {
- clearCache bool // clearCache drops caches before running.
- fstype string // type of filesystem to use.
+ clearCache bool // clearCache drops caches before running.
+ fstype harness.FileSystemType // type of filesystem to use.
}
// Note: CleanCache versions of this test require running with root permissions.
@@ -48,12 +49,12 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
// Get a machine from the Harness on which to run.
machine, err := harness.GetMachine()
if err != nil {
- b.Fatalf("failed to get machine: %v", err)
+ b.Fatalf("Failed to get machine: %v", err)
}
defer machine.CleanUp()
benchmarks := make([]benchmark, 0, 6)
- for _, filesys := range []string{harness.BindFS, harness.TmpFS, harness.RootFS} {
+ for _, filesys := range []harness.FileSystemType{harness.BindFS, harness.TmpFS, harness.RootFS} {
benchmarks = append(benchmarks, benchmark{
clearCache: true,
fstype: filesys,
@@ -75,7 +76,7 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
filesystem := tools.Parameter{
Name: "filesystem",
- Value: bm.fstype,
+ Value: string(bm.fstype),
}
name, err := tools.ParametersToName(pageCache, filesystem)
if err != nil {
@@ -86,13 +87,14 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
// Grab a container.
ctx := context.Background()
container := machine.GetContainer(ctx, b)
- defer container.CleanUp(ctx)
-
- mts, prefix, cleanup, err := harness.MakeMount(machine, bm.fstype)
+ cu := cleanup.Make(func() {
+ container.CleanUp(ctx)
+ })
+ defer cu.Clean()
+ mts, prefix, err := harness.MakeMount(machine, bm.fstype, &cu)
if err != nil {
b.Fatalf("Failed to make mount: %v", err)
}
- defer cleanup()
runOpts := dockerutil.RunOpts{
Image: image,
@@ -104,8 +106,9 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
b.Fatalf("run failed with: %v", err)
}
+ cpCmd := fmt.Sprintf("mkdir -p %s && cp -r %s %s/.", prefix, workdir, prefix)
if out, err := container.Exec(ctx, dockerutil.ExecOpts{},
- "cp", "-rf", workdir, prefix+"/."); err != nil {
+ "/bin/sh", "-c", cpCmd); err != nil {
b.Fatalf("failed to copy directory: %v (%s)", err, out)
}
diff --git a/test/benchmarks/fs/fio_test.go b/test/benchmarks/fs/fio_test.go
index f783a2b33..1482466f4 100644
--- a/test/benchmarks/fs/fio_test.go
+++ b/test/benchmarks/fs/fio_test.go
@@ -21,6 +21,7 @@ import (
"strings"
"testing"
+ "gvisor.dev/gvisor/pkg/cleanup"
"gvisor.dev/gvisor/pkg/test/dockerutil"
"gvisor.dev/gvisor/test/benchmarks/harness"
"gvisor.dev/gvisor/test/benchmarks/tools"
@@ -69,7 +70,7 @@ func BenchmarkFio(b *testing.B) {
}
defer machine.CleanUp()
- for _, fsType := range []string{harness.BindFS, harness.TmpFS, harness.RootFS} {
+ for _, fsType := range []harness.FileSystemType{harness.BindFS, harness.TmpFS, harness.RootFS} {
for _, tc := range testCases {
operation := tools.Parameter{
Name: "operation",
@@ -81,7 +82,7 @@ func BenchmarkFio(b *testing.B) {
}
filesystem := tools.Parameter{
Name: "filesystem",
- Value: fsType,
+ Value: string(fsType),
}
name, err := tools.ParametersToName(operation, blockSize, filesystem)
if err != nil {
@@ -90,15 +91,18 @@ func BenchmarkFio(b *testing.B) {
b.Run(name, func(b *testing.B) {
b.StopTimer()
tc.Size = b.N
+
ctx := context.Background()
container := machine.GetContainer(ctx, b)
- defer container.CleanUp(ctx)
+ cu := cleanup.Make(func() {
+ container.CleanUp(ctx)
+ })
+ defer cu.Clean()
- mnts, outdir, mountCleanup, err := harness.MakeMount(machine, fsType)
+ mnts, outdir, err := harness.MakeMount(machine, fsType, &cu)
if err != nil {
b.Fatalf("failed to make mount: %v", err)
}
- defer mountCleanup()
// Start the container with the mount.
if err := container.Spawn(
@@ -112,6 +116,11 @@ func BenchmarkFio(b *testing.B) {
b.Fatalf("failed to start fio container with: %v", err)
}
+ if out, err := container.Exec(ctx, dockerutil.ExecOpts{},
+ "mkdir", "-p", outdir); err != nil {
+ b.Fatalf("failed to copy directory: %v (%s)", err, out)
+ }
+
// Directory and filename inside container where fio will read/write.
outfile := filepath.Join(outdir, "test.txt")
@@ -130,7 +139,6 @@ func BenchmarkFio(b *testing.B) {
}
cmd := tc.MakeCmd(outfile)
-
if err := harness.DropCaches(machine); err != nil {
b.Fatalf("failed to drop caches: %v", err)
}