From 8a1ebd15a3f53bc764934793a10b727b62c64966 Mon Sep 17 00:00:00 2001 From: starptech Date: Wed, 17 Nov 2021 10:45:46 +0100 Subject: [PATCH 1/2] add note about github action and release mode for build perf --- README.md | 4 ++++ lib/src/execute.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index e48741e9..716d1f1b 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ To install Viceroy as a standalone tool, you'll need to first Then run `cargo install viceroy`, which will download and build the latest Viceroy release. +## Usage as a library + +Viceroy can be used as a [Rust library](https://docs.rs/viceroy-lib/). This is useful if you want to run integration tests in the same codebase. We provide a helper method [`handle_request`](https://docs.rs/viceroy-lib/0.2.6/viceroy_lib/struct.ExecuteCtx.html#method.handle_request). Before you build or test your code, we recommend to set the release flag e.g. `cargo test --release` otherwise, the execution will be very slow. This has to do with the Cranelift compiler, which is extremely slow when compiled in debug mode. Besides that, if you use Github Actions don't forget to setup a build [cache](https://github.com/actions/cache/blob/main/examples.md#rust---cargo) for Rust. This will speed up your build times a lot. + ## Usage as a standalone tool **NOTE**: the Viceroy standalone CLI has a somewhat different interface from that diff --git a/lib/src/execute.rs b/lib/src/execute.rs index 1dbaace2..e94e2582 100644 --- a/lib/src/execute.rs +++ b/lib/src/execute.rs @@ -166,6 +166,10 @@ impl ExecuteCtx { /// including running the wasm start function. It then proceeds to execute the /// instantiated module's WASI entry point, running to completion. If execution /// results in an error, a response is still produced, but with a 500 status code. + /// + /// Build time: Before you build or test your code, we recommend to set the release flag e.g. `cargo test --release` otherwise, + /// the execution will be very slow. This has to do with the Cranelift compiler, + /// which is extremely slow when compiled in debug mode. /// /// # Example /// From c1e97b9dab5f3971e356441014e9d20e7b938760 Mon Sep 17 00:00:00 2001 From: starptech Date: Wed, 17 Nov 2021 10:47:21 +0100 Subject: [PATCH 2/2] format code --- lib/src/execute.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/execute.rs b/lib/src/execute.rs index e94e2582..2553d275 100644 --- a/lib/src/execute.rs +++ b/lib/src/execute.rs @@ -166,10 +166,10 @@ impl ExecuteCtx { /// including running the wasm start function. It then proceeds to execute the /// instantiated module's WASI entry point, running to completion. If execution /// results in an error, a response is still produced, but with a 500 status code. - /// - /// Build time: Before you build or test your code, we recommend to set the release flag e.g. `cargo test --release` otherwise, - /// the execution will be very slow. This has to do with the Cranelift compiler, - /// which is extremely slow when compiled in debug mode. + /// + /// Build time: Before you build or test your code, we recommend to set the release flag + /// e.g. `cargo test --release` otherwise the execution will be very slow. This has to do + /// with the Cranelift compiler, which is extremely slow when compiled in debug mode. /// /// # Example ///