Make hostcall CPU profiling configurable
This commit is contained in:
+3
-2
@@ -125,6 +125,7 @@ struct WasmWorkerConfig
|
||||
u32 table_headroom = 4096;
|
||||
u64 epoch_deadline_ticks = 200; // ticker period × ticks = CPU budget
|
||||
u64 mysql_persistent_pool_size = 8;
|
||||
bool profile_hostcall_cpu = true;
|
||||
bool verbose = false;
|
||||
// uce_host_* names (bare, without the "uce_host_" prefix) the sysadmin has
|
||||
// disabled via UCE_HOSTCALL_BLOCKLIST. A blocked hostcall resolves to a trap
|
||||
@@ -2238,14 +2239,14 @@ private:
|
||||
bool profile_memcache = name == "uce_host_memcache_command";
|
||||
auto profiled = [self, callback, profile_index, profile_enabled, profile_mysql, profile_memcache](Caller caller, Span<const Val> args, Span<Val> results) mutable -> Result<std::monostate, Trap> {
|
||||
auto started = std::chrono::steady_clock::now();
|
||||
f64 cpu_started = profile_enabled ? wasm_thread_cpu_time() : 0;
|
||||
f64 cpu_started = profile_enabled && self->worker.cfg.profile_hostcall_cpu ? wasm_thread_cpu_time() : 0;
|
||||
auto result = callback(caller, args, results);
|
||||
// Epoch interruption limits guest CPU, not time spent in native I/O,
|
||||
// process management, hashing, or other host work. Re-arm at the one
|
||||
// membrane every hostcall crosses so newly added blocking imports
|
||||
// cannot silently consume the next guest segment's budget.
|
||||
caller.context().set_epoch_deadline(self->worker.cfg.epoch_deadline_ticks);
|
||||
f64 cpu_finished = profile_enabled ? wasm_thread_cpu_time() : 0;
|
||||
f64 cpu_finished = profile_enabled && self->worker.cfg.profile_hostcall_cpu ? wasm_thread_cpu_time() : 0;
|
||||
if(profile_enabled)
|
||||
{
|
||||
u64 elapsed = (u64)std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - started).count();
|
||||
|
||||
Reference in New Issue
Block a user