Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/proxy-wasm/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace proxy_wasm {

bool initV8Engine();
std::unique_ptr<WasmVm> createV8Vm();

} // namespace proxy_wasm
1 change: 0 additions & 1 deletion include/proxy-wasm/wamr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace proxy_wasm {

bool initWamrEngine();
std::unique_ptr<WasmVm> createWamrVm();

} // namespace proxy_wasm
1 change: 0 additions & 1 deletion include/proxy-wasm/wasmtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace proxy_wasm {

bool initWasmtimeEngine();
std::unique_ptr<WasmVm> createWasmtimeVm();

} // namespace proxy_wasm
2 changes: 0 additions & 2 deletions src/v8/v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,6 @@ std::string V8::getFailMessage(std::string_view function_name, wasm::own<wasm::T

} // namespace v8

bool initV8Engine() { return v8::engine() != nullptr; }

std::unique_ptr<WasmVm> createV8Vm() { return std::make_unique<v8::V8>(); }

} // namespace proxy_wasm
2 changes: 0 additions & 2 deletions src/wamr/wamr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,6 @@ void Wamr::warm() { initStore(); }

} // namespace wamr

bool initWamrEngine() { return wamr::engine() != nullptr; }

std::unique_ptr<WasmVm> createWamrVm() { return std::make_unique<wamr::Wamr>(); }

} // namespace proxy_wasm
2 changes: 0 additions & 2 deletions src/wasmtime/wasmtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,6 @@ void Wasmtime::warm() { initStore(); }

} // namespace wasmtime

bool initWasmtimeEngine() { return wasmtime::engine() != nullptr; }

std::unique_ptr<WasmVm> createWasmtimeVm() { return std::make_unique<wasmtime::Wasmtime>(); }

} // namespace proxy_wasm
36 changes: 11 additions & 25 deletions test/wasm_vm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,17 @@ INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()
});

TEST_P(TestVm, Init) {
std::chrono::time_point<std::chrono::steady_clock> 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<std::chrono::nanoseconds>(time2 - time1).count();
auto warm = std::chrono::duration_cast<std::chrono::nanoseconds>(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;
Expand All @@ -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.
Comment on lines +58 to +59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe try moving things inside WasmEdge implementation to keep warming-up consistent across all engines, or error out in warm() to signal that it doesn't work.

Alternatively, as discussed in on of the meetings, it's worth considering whether we want to keep WasmEdge at all, since it hasn't been updated in a while, and I'm not aware of anyone using it. cc @mpwarres

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing WasmEdge SGTM.

if (engine_ == "null" || engine_ == "wasmedge") {
std::cout << "Skipping warm() performance assertions for NullVm." << std::endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This error doesn't mention WasmEdge. Either include the engine_ in the output or split it into two ifs.

return;
}
EXPECT_LE(warm * 50, cold);
}

Expand Down
Loading