Profile logical MySQL operations
This commit is contained in:
+34
-1
@@ -99,6 +99,12 @@ struct WasmWorkerConfig
|
||||
std::set<String> hostcall_blocklist;
|
||||
};
|
||||
|
||||
struct WasmMySQLOperation
|
||||
{
|
||||
String op;
|
||||
u64 elapsed_us = 0;
|
||||
};
|
||||
|
||||
struct WasmRequestProfile
|
||||
{
|
||||
u64 dispatch_us = 0;
|
||||
@@ -111,6 +117,9 @@ struct WasmRequestProfile
|
||||
u64 hostcall_total_us = 0;
|
||||
u64 mysql_hostcall_count = 0;
|
||||
u64 mysql_hostcall_total_us = 0;
|
||||
u64 mysql_operation_count = 0;
|
||||
u64 mysql_operations_dropped = 0;
|
||||
std::vector<WasmMySQLOperation> mysql_operations;
|
||||
u64 memcache_hostcall_count = 0;
|
||||
u64 memcache_hostcall_total_us = 0;
|
||||
};
|
||||
@@ -1769,6 +1778,16 @@ private:
|
||||
response["hostcall_us"] = (f64)self->hostcall_total_us;
|
||||
response["mysql_hostcall_count"] = (f64)self->mysql_hostcall_count;
|
||||
response["mysql_hostcall_us"] = (f64)self->mysql_hostcall_total_us;
|
||||
response["mysql_operation_count"] = (f64)self->mysql_operation_count;
|
||||
response["mysql_operations_dropped"] = (f64)self->mysql_operations_dropped;
|
||||
response["mysql_operations"].set_array();
|
||||
for(auto& operation : self->mysql_operations)
|
||||
{
|
||||
DValue item;
|
||||
item["op"] = operation.op;
|
||||
item["us"] = (f64)operation.elapsed_us;
|
||||
response["mysql_operations"].push(item);
|
||||
}
|
||||
response["memcache_hostcall_count"] = (f64)self->memcache_hostcall_count;
|
||||
response["memcache_hostcall_us"] = (f64)self->memcache_hostcall_total_us;
|
||||
response["component_resolve_count"] = (f64)self->component_resolve_count;
|
||||
@@ -2480,9 +2499,11 @@ private:
|
||||
{
|
||||
DValue request, response;
|
||||
String decode_error;
|
||||
String op;
|
||||
auto operation_started = std::chrono::steady_clock::now();
|
||||
if(ucb_decode(encoded, request, &decode_error))
|
||||
{
|
||||
String op = request["op"].to_string();
|
||||
op = request["op"].to_string();
|
||||
if(op == "connect")
|
||||
{
|
||||
String host = request["host"].to_string();
|
||||
@@ -2546,6 +2567,18 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
if(op != "")
|
||||
{
|
||||
WasmMySQLOperation operation;
|
||||
operation.op = op;
|
||||
operation.elapsed_us = (u64)std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::steady_clock::now() - operation_started).count();
|
||||
self->mysql_operation_count++;
|
||||
if(self->mysql_operations.size() < 64)
|
||||
self->mysql_operations.push_back(operation);
|
||||
else
|
||||
self->mysql_operations_dropped++;
|
||||
}
|
||||
out = ucb_encode(response);
|
||||
if(buf == 0)
|
||||
self->hostcall_stage(stage_key, out);
|
||||
|
||||
Reference in New Issue
Block a user