Cache immutable Wasm server configuration encoding
This commit is contained in:
+11
-4
@@ -187,6 +187,7 @@ struct WasmRequestProfile
|
||||
u64 context_apply_us = 0;
|
||||
u64 context_apply_cpu_us = 0;
|
||||
u64 context_bytes = 0;
|
||||
u64 server_config_bytes = 0;
|
||||
u64 context_encode_us = 0;
|
||||
u64 context_allocate_us = 0;
|
||||
u64 context_write_us = 0;
|
||||
@@ -978,6 +979,7 @@ public:
|
||||
std::optional<wasmtime::Linker> core_linker;
|
||||
std::unique_ptr<wasmtime_instance_pre_t, WasmInstancePreDeleter> core_instance_pre;
|
||||
DValue server_config_context;
|
||||
String server_config_encoded;
|
||||
struct CoreImport
|
||||
{
|
||||
String module;
|
||||
@@ -1532,21 +1534,25 @@ public:
|
||||
return(elapsed);
|
||||
};
|
||||
String encoded = ucb_encode(context_tree);
|
||||
context_bytes = encoded.size();
|
||||
server_config_bytes = worker.server_config_encoded.size();
|
||||
context_bytes = server_config_bytes + encoded.size();
|
||||
context_encode_us = phase_us();
|
||||
int32_t guest_ptr = 0;
|
||||
String error = call_core("uce_alloc", { (int32_t)encoded.size() }, &guest_ptr);
|
||||
String error = call_core("uce_alloc", { (int32_t)context_bytes }, &guest_ptr);
|
||||
context_allocate_us = phase_us();
|
||||
if(error != "")
|
||||
return(error);
|
||||
if(guest_ptr == 0)
|
||||
return("guest uce_alloc failed for context buffer");
|
||||
error = guest_write((u32)guest_ptr, encoded);
|
||||
error = guest_write((u32)guest_ptr, worker.server_config_encoded);
|
||||
if(error == "")
|
||||
error = guest_write((u32)guest_ptr + (u32)server_config_bytes, encoded);
|
||||
context_write_us = phase_us();
|
||||
if(error != "")
|
||||
return(error);
|
||||
int32_t rc = 0;
|
||||
error = call_core("uce_wasm_apply_context", { guest_ptr, (int32_t)encoded.size() }, &rc);
|
||||
error = call_core("uce_wasm_apply_context", { guest_ptr, (int32_t)server_config_bytes,
|
||||
guest_ptr + (int32_t)server_config_bytes, (int32_t)encoded.size() }, &rc);
|
||||
context_guest_apply_us = phase_us();
|
||||
if(error != "")
|
||||
return(error);
|
||||
@@ -2592,6 +2598,7 @@ private:
|
||||
response["context_apply_us"] = (f64)self->context_apply_us;
|
||||
response["context_apply_cpu_us"] = (f64)self->context_apply_cpu_us;
|
||||
response["context_bytes"] = (f64)self->context_bytes;
|
||||
response["server_config_bytes"] = (f64)self->server_config_bytes;
|
||||
response["context_encode_us"] = (f64)self->context_encode_us;
|
||||
response["context_allocate_us"] = (f64)self->context_allocate_us;
|
||||
response["context_write_us"] = (f64)self->context_write_us;
|
||||
|
||||
Reference in New Issue
Block a user