From 2a3de1196c38af7e2357642e80e5d96e46add507 Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Wed, 17 Sep 2025 17:17:19 +0000 Subject: [PATCH 1/2] Remove the init*engine methods from runtimes, and update warm() test. Signed-off-by: Rachel Green --- include/proxy-wasm/v8.h | 1 - include/proxy-wasm/wamr.h | 1 - include/proxy-wasm/wasmtime.h | 1 - src/v8/v8.cc | 2 -- src/wamr/wamr.cc | 2 -- src/wasmtime/wasmtime.cc | 2 -- test/wasm_vm_test.cc | 36 +++++++++++------------------------ 7 files changed, 11 insertions(+), 34 deletions(-) diff --git a/include/proxy-wasm/v8.h b/include/proxy-wasm/v8.h index 5531f52cb..73c91b956 100644 --- a/include/proxy-wasm/v8.h +++ b/include/proxy-wasm/v8.h @@ -21,7 +21,6 @@ namespace proxy_wasm { -bool initV8Engine(); std::unique_ptr createV8Vm(); } // namespace proxy_wasm diff --git a/include/proxy-wasm/wamr.h b/include/proxy-wasm/wamr.h index 32a05e94a..98ff72e31 100644 --- a/include/proxy-wasm/wamr.h +++ b/include/proxy-wasm/wamr.h @@ -21,7 +21,6 @@ namespace proxy_wasm { -bool initWamrEngine(); std::unique_ptr createWamrVm(); } // namespace proxy_wasm diff --git a/include/proxy-wasm/wasmtime.h b/include/proxy-wasm/wasmtime.h index 11c4ae7a3..e3fe4b48c 100644 --- a/include/proxy-wasm/wasmtime.h +++ b/include/proxy-wasm/wasmtime.h @@ -18,7 +18,6 @@ namespace proxy_wasm { -bool initWasmtimeEngine(); std::unique_ptr createWasmtimeVm(); } // namespace proxy_wasm diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 9e184f292..f51cdfffa 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -755,8 +755,6 @@ std::string V8::getFailMessage(std::string_view function_name, wasm::own createV8Vm() { return std::make_unique(); } } // namespace proxy_wasm diff --git a/src/wamr/wamr.cc b/src/wamr/wamr.cc index 88dc9f007..8eef73590 100644 --- a/src/wamr/wamr.cc +++ b/src/wamr/wamr.cc @@ -713,8 +713,6 @@ void Wamr::warm() { initStore(); } } // namespace wamr -bool initWamrEngine() { return wamr::engine() != nullptr; } - std::unique_ptr createWamrVm() { return std::make_unique(); } } // namespace proxy_wasm diff --git a/src/wasmtime/wasmtime.cc b/src/wasmtime/wasmtime.cc index ac0361623..a72a0361d 100644 --- a/src/wasmtime/wasmtime.cc +++ b/src/wasmtime/wasmtime.cc @@ -710,8 +710,6 @@ void Wasmtime::warm() { initStore(); } } // namespace wasmtime -bool initWasmtimeEngine() { return wasmtime::engine() != nullptr; } - std::unique_ptr createWasmtimeVm() { return std::make_unique(); } } // namespace proxy_wasm diff --git a/test/wasm_vm_test.cc b/test/wasm_vm_test.cc index bb2bab193..72d48624b 100644 --- a/test/wasm_vm_test.cc +++ b/test/wasm_vm_test.cc @@ -31,37 +31,17 @@ INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines() }); TEST_P(TestVm, Init) { - std::chrono::time_point time2; - auto time1 = std::chrono::steady_clock::now(); - if (engine_ == "v8") { -#if defined(PROXY_WASM_HOST_ENGINE_V8) - EXPECT_TRUE(proxy_wasm::initV8Engine()); - time2 = std::chrono::steady_clock::now(); - EXPECT_TRUE(proxy_wasm::initV8Engine()); -#endif - } else if (engine_ == "wamr") { -#if defined(PROXY_WASM_HOST_ENGINE_WAMR) - EXPECT_TRUE(proxy_wasm::initWamrEngine()); - time2 = std::chrono::steady_clock::now(); - EXPECT_TRUE(proxy_wasm::initWamrEngine()); -#endif - } else if (engine_ == "wasmtime") { -#if defined(PROXY_WASM_HOST_ENGINE_WASMTIME) - EXPECT_TRUE(proxy_wasm::initWasmtimeEngine()); - time2 = std::chrono::steady_clock::now(); - EXPECT_TRUE(proxy_wasm::initWasmtimeEngine()); -#endif - } else { - return; - } + vm_->warm(); + auto time2 = std::chrono::steady_clock::now(); + vm_->warm(); auto time3 = std::chrono::steady_clock::now(); auto cold = std::chrono::duration_cast(time2 - time1).count(); auto warm = std::chrono::duration_cast(time3 - time2).count(); - std::cout << "\"cold\" engine time: " << cold << "ns" << std::endl; - std::cout << "\"warm\" engine time: " << warm << "ns" << std::endl; + std::cout << "[" << engine_ << "] \"cold\" engine time: " << cold << "ns" << std::endl; + std::cout << "[" << engine_ << "] \"warm\" engine time: " << warm << "ns" << std::endl; // Default warm time in nanoseconds. int warm_time_ns_limit = 10000; @@ -75,6 +55,12 @@ TEST_P(TestVm, Init) { EXPECT_LE(warm, warm_time_ns_limit); // Verify that getting a "warm" engine takes at least 50x less time than getting a "cold" one. + // We skip NullVM because warm() is a noop, and we skip wasmedge because its engine is initialized + // in the constructor vs. on cold start. + if (engine_ == "null" || engine_ == "wasmedge") { + std::cout << "Skipping warm() performance assertions for NullVm." << std::endl; + return; + } EXPECT_LE(warm * 50, cold); } From d1c8ac891d1ffdd213a806091b15aa0d745d1dc2 Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Fri, 3 Oct 2025 15:34:49 +0000 Subject: [PATCH 2/2] Nit- updated error message to include engine_ name. Signed-off-by: Rachel Green --- test/wasm_vm_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/wasm_vm_test.cc b/test/wasm_vm_test.cc index 72d48624b..e49d9835d 100644 --- a/test/wasm_vm_test.cc +++ b/test/wasm_vm_test.cc @@ -58,7 +58,7 @@ TEST_P(TestVm, Init) { // We skip NullVM because warm() is a noop, and we skip wasmedge because its engine is initialized // in the constructor vs. on cold start. if (engine_ == "null" || engine_ == "wasmedge") { - std::cout << "Skipping warm() performance assertions for NullVm." << std::endl; + std::cout << "Skipping warm() performance assertions for " << engine_ << "." << std::endl; return; } EXPECT_LE(warm * 50, cold);