Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi: benchmarks fd_readdir for both real and fake file systems #910

Merged
merged 5 commits into from
Dec 11, 2022

Conversation

codefromthecrypt
Copy link
Contributor

It is likely we'll have to special-case real files in wasi, as wasi-libc makes behavioral choices based on presence of non-zero inode data. This adds a defensive benchmark, so that we know what our performance base case is. This adds both real and fake file systems as both patterns are in use today.

$ go test -run='^$' -bench '^Benchmark_fdReaddir$'
goos: darwin
goarch: amd64
pkg: github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Benchmark_fdReaddir/embed.FS-16         	  457398	      2416 ns/op
Benchmark_fdReaddir/os.DirFS-16         	   45662	     26271 ns/op
PASS
ok  	github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1	35.632s

See https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-17 and WebAssembly/wasi-filesystem#65

cc @jerbob92

It is likely we'll have to special-case real files in wasi, as wasi-libc
makes behavioral choices based on presence of non-zero inode data. This
adds a defensive benchmark, so that we know what our performance base
case is. This adds both real and fake file systems as both patterns are
in use today.

```bash
$ go test -run='^$' -bench '^Benchmark_fdReaddir$'
goos: darwin
goarch: amd64
pkg: github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Benchmark_fdReaddir/embed.FS-16         	  457398	      2416 ns/op
Benchmark_fdReaddir/os.DirFS-16         	   45662	     26271 ns/op
PASS
ok  	github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1	35.632s
```

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Adrian Cole added 2 commits December 9, 2022 17:38
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Dec 9, 2022

I added a benchmark of a continued read. This reads the same amount of dirents, but some from memory and rest from disk.

Benchmark_fdReaddir
Benchmark_fdReaddir/embed.FS
Benchmark_fdReaddir/embed.FS-16                    	  443401	      2460 ns/op	     384 B/op	       5 allocs/op
Benchmark_fdReaddir/embed.FS_-_continued
Benchmark_fdReaddir/embed.FS_-_continued-16        	  548738	      2173 ns/op	     288 B/op	       4 allocs/op
Benchmark_fdReaddir/os.DirFS
Benchmark_fdReaddir/os.DirFS-16                    	   44121	     27032 ns/op	    2648 B/op	      30 allocs/op
Benchmark_fdReaddir/os.DirFS_-_continued
Benchmark_fdReaddir/os.DirFS_-_continued-16        	  252295	      5047 ns/op	    2096 B/op	      21 allocs/op

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt codefromthecrypt merged commit e49995c into main Dec 11, 2022
@codefromthecrypt codefromthecrypt deleted the bench-readdir branch December 11, 2022 22:53
@codefromthecrypt
Copy link
Contributor Author

Thanks for the help again @jerbob92. I'll implement the fstat next, since we can see how much it costs now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants