From fc3b30279bddc3221dddd9b3393f9f36b682ee0c Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Mon, 13 Feb 2023 15:05:16 +0900 Subject: [PATCH] Add performance note --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index bdc897f..fe436e0 100644 --- a/README.md +++ b/README.md @@ -26,5 +26,25 @@ Additionally, add `-gc=custom` and `-tags=custommalloc` to your TinyGo build fla tinygo build -o main.wasm -gc=custom -tags=custommalloc -target=wasi -scheduler=none main.go ``` +## Performance + +Benchmarks are run against every commit in the [bench][4] workflow. GitHub action runners are highly +virtualized and do not have stable performance across runs, but the relative numbers within a run +should still be somewhat, though not precisely, informative. + +One run looks like this + +``` +BenchmarkGC/bench.wasm-2 52 220294559 ns/op +BenchmarkGC/benchref.wasm-2 6 2000167805 ns/op +``` + +The benchmark is very simple, allocating some large strings in a loop. We see nottinygc perform almost +10x better in this benchmark. Note that just allocation / collection time is not the only aspect of +GC performance, allocation locality and fragmentation can also affect performance of real-world +applications. We have found that the default allocator can cause applications to run out of memory, +possibly due to fragmentation, whereas this library will continue to run indefinitely. + [1]: https://github.com/ivmai/bdwgc [2]: https://github.com/microsoft/mimalloc +[4]: https://github.com/wasilibs/nottinygc/actions/workflows/bench.yaml \ No newline at end of file