You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-8Lines changed: 38 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,24 +15,32 @@ A webserver [platform](https://github.com/roc-lang/roc/wiki/Roc-concepts-explain
15
15
Run this example server with `$ roc helloweb.roc` (on linux, add `--linker=legacy`) and go to `http://localhost:8000` in your browser. You can change the port (8000) and the host (localhost) by setting the environment variables ROC_BASIC_WEBSERVER_PORT and ROC_BASIC_WEBSERVER_HOST.
@@ -43,3 +51,25 @@ If you'd like to contribute, check out our [group chat](https://roc.zulipchat.co
43
51
## Developing / Building Locally
44
52
45
53
If you have cloned this repository and want to run the examples without using a packaged release (...tar.br), you will need to build the platform first by running `roc build.roc`. Run examples with `roc examples/hello.roc` (on linux, add `--linker=legacy`).
54
+
55
+
## Benchmarking
56
+
57
+
Basic webserver should have decent performance due to being built on top of Rust's [hyper](https://hyper.rs).
58
+
That said, it has a few known issues that hurt performance:
59
+
1. We do [extra data copying on every request](https://github.com/roc-lang/basic-webserver/issues/23).
60
+
2. Until roc has effect interpreters, basic-webserver can only do blocking io for effects. To work around this, every request is spawned in a blocking thread.
61
+
3. Until [sqlite improvements](https://github.com/roc-lang/basic-webserver/pull/61) land, we never prepare queries.
62
+
63
+
That said, running benchmarks and debugging performance is still a great idea. It can help improve both Roc and basic-webserver.
64
+
65
+
Lots of load generators exist. Generally, it is advised to use one that avoids [coordinated omission](https://www.youtube.com/watch?v=lJ8ydIuPFeU).
66
+
A trusted generator that fits this criteria is [wrk2](https://github.com/giltene/wrk2) (sadly doesn't work on Apple Silicon).
67
+
68
+
If you are benchmarking on a single machine, you can use the `TOKIO_WORKER_THREADS` environment variable to limit parallelism of the webserver.
69
+
70
+
> Note: When benchmarking, it is best to run the load generator and the webserver on different machines.
71
+
72
+
When benchmarking on a single 8 core machine with `wrk2`, these commands could be used (simply tune connections `-c` and rate `-R`):
0 commit comments