Skip to content

Commit 2a3de11

Browse files
committed
Remove the init*engine methods from runtimes, and update warm() test.
Signed-off-by: Rachel Green <[email protected]>
1 parent 8b2e653 commit 2a3de11

File tree

7 files changed

+11
-34
lines changed

7 files changed

+11
-34
lines changed

include/proxy-wasm/v8.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
namespace proxy_wasm {
2323

24-
bool initV8Engine();
2524
std::unique_ptr<WasmVm> createV8Vm();
2625

2726
} // namespace proxy_wasm

include/proxy-wasm/wamr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
namespace proxy_wasm {
2323

24-
bool initWamrEngine();
2524
std::unique_ptr<WasmVm> createWamrVm();
2625

2726
} // namespace proxy_wasm

include/proxy-wasm/wasmtime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
namespace proxy_wasm {
2020

21-
bool initWasmtimeEngine();
2221
std::unique_ptr<WasmVm> createWasmtimeVm();
2322

2423
} // namespace proxy_wasm

src/v8/v8.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,6 @@ std::string V8::getFailMessage(std::string_view function_name, wasm::own<wasm::T
755755

756756
} // namespace v8
757757

758-
bool initV8Engine() { return v8::engine() != nullptr; }
759-
760758
std::unique_ptr<WasmVm> createV8Vm() { return std::make_unique<v8::V8>(); }
761759

762760
} // namespace proxy_wasm

src/wamr/wamr.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,6 @@ void Wamr::warm() { initStore(); }
713713

714714
} // namespace wamr
715715

716-
bool initWamrEngine() { return wamr::engine() != nullptr; }
717-
718716
std::unique_ptr<WasmVm> createWamrVm() { return std::make_unique<wamr::Wamr>(); }
719717

720718
} // namespace proxy_wasm

src/wasmtime/wasmtime.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,6 @@ void Wasmtime::warm() { initStore(); }
710710

711711
} // namespace wasmtime
712712

713-
bool initWasmtimeEngine() { return wasmtime::engine() != nullptr; }
714-
715713
std::unique_ptr<WasmVm> createWasmtimeVm() { return std::make_unique<wasmtime::Wasmtime>(); }
716714

717715
} // namespace proxy_wasm

test/wasm_vm_test.cc

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,17 @@ INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()
3131
});
3232

3333
TEST_P(TestVm, Init) {
34-
std::chrono::time_point<std::chrono::steady_clock> time2;
35-
3634
auto time1 = std::chrono::steady_clock::now();
37-
if (engine_ == "v8") {
38-
#if defined(PROXY_WASM_HOST_ENGINE_V8)
39-
EXPECT_TRUE(proxy_wasm::initV8Engine());
40-
time2 = std::chrono::steady_clock::now();
41-
EXPECT_TRUE(proxy_wasm::initV8Engine());
42-
#endif
43-
} else if (engine_ == "wamr") {
44-
#if defined(PROXY_WASM_HOST_ENGINE_WAMR)
45-
EXPECT_TRUE(proxy_wasm::initWamrEngine());
46-
time2 = std::chrono::steady_clock::now();
47-
EXPECT_TRUE(proxy_wasm::initWamrEngine());
48-
#endif
49-
} else if (engine_ == "wasmtime") {
50-
#if defined(PROXY_WASM_HOST_ENGINE_WASMTIME)
51-
EXPECT_TRUE(proxy_wasm::initWasmtimeEngine());
52-
time2 = std::chrono::steady_clock::now();
53-
EXPECT_TRUE(proxy_wasm::initWasmtimeEngine());
54-
#endif
55-
} else {
56-
return;
57-
}
35+
vm_->warm();
36+
auto time2 = std::chrono::steady_clock::now();
37+
vm_->warm();
5838
auto time3 = std::chrono::steady_clock::now();
5939

6040
auto cold = std::chrono::duration_cast<std::chrono::nanoseconds>(time2 - time1).count();
6141
auto warm = std::chrono::duration_cast<std::chrono::nanoseconds>(time3 - time2).count();
6242

63-
std::cout << "\"cold\" engine time: " << cold << "ns" << std::endl;
64-
std::cout << "\"warm\" engine time: " << warm << "ns" << std::endl;
43+
std::cout << "[" << engine_ << "] \"cold\" engine time: " << cold << "ns" << std::endl;
44+
std::cout << "[" << engine_ << "] \"warm\" engine time: " << warm << "ns" << std::endl;
6545

6646
// Default warm time in nanoseconds.
6747
int warm_time_ns_limit = 10000;
@@ -75,6 +55,12 @@ TEST_P(TestVm, Init) {
7555
EXPECT_LE(warm, warm_time_ns_limit);
7656

7757
// Verify that getting a "warm" engine takes at least 50x less time than getting a "cold" one.
58+
// We skip NullVM because warm() is a noop, and we skip wasmedge because its engine is initialized
59+
// in the constructor vs. on cold start.
60+
if (engine_ == "null" || engine_ == "wasmedge") {
61+
std::cout << "Skipping warm() performance assertions for NullVm." << std::endl;
62+
return;
63+
}
7864
EXPECT_LE(warm * 50, cold);
7965
}
8066

0 commit comments

Comments
 (0)