feat: implement high-precision performance tracing in executor#256
feat: implement high-precision performance tracing in executor#256vansham wants to merge 4 commits intogenlayerlabs:mainfrom
Conversation
Added performance tracing by tracking execution time and logging metrics.
📝 WalkthroughWalkthroughAdds execution-time instrumentation to the executor and expands configuration validation: introduces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
executor/src/lib.rs (1)
98-201: Timing is skipped on early error paths
Thevm.run().await?and the VM-error early return bypass the log block, so failed calls won’t emit timing even though the intent is “every call.” Consider logging before propagating errors or using a small guard to ensure the log fires on all exits.🛠️ Minimal fix to log even when vm.run() fails
- let run_result = vm.run().await?; + let run_result = vm.run().await; // --- LOG PERFORMANCE METRICS --- let exec_duration = start_instant.elapsed().as_micros(); log_info!( contract = %entry_data.message.contract_address, duration_us = %exec_duration; "Intelligent Contract execution performance trace" ); // ------------------------------- + + let run_result = run_result?;(You’ll still want to route the earlier VM-error return through the same logging path or a guard to cover that branch too.)
🤖 Fix all issues with AI agents
In `@executor/src/lib.rs`:
- Around line 31-33: The Metrics struct's execution_time_us field is never set
so serialized metrics stay zero; either remove the field or wire it to the
actual exec duration: locate where exec_duration is computed in run_with and
assign that value (converted to u128 microseconds) into
Metrics::execution_time_us before serializing/sending, ensuring proper
synchronization if Metrics is shared across threads, or remove execution_time_us
from the Metrics definition and any serialization/consumption sites (and keep
only the logging of exec_duration) to avoid misleading data.
Updated log message to include shared data population and refined comment structure.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@executor/src/lib.rs`:
- Around line 98-100: The timing start (let start_instant = Instant::now()) is
only recorded on the happy path and early returns skip setting execution_time_us
and the log; introduce a small RAII/Drop guard (e.g., ExecutionTimerGuard)
created where start_instant is now, have its Drop impl compute duration, update
execution_time_us and emit the log/metrics, and ensure any references to
start_instant are replaced by or use the guard so that timing is recorded on all
exit paths (including errors and panics); attach the guard at the top of the
function scope that currently contains start_instant so it runs regardless of
how the function returns.
Added serialization support and validation method for Config.
Added configuration validation to ensure proper setup before proceeding.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@executor/src/config.rs`:
- Around line 26-45: The Config::validate method is missing the log_info! macro
import and omits validation for registry_dir; fix by adding the common import
(e.g., bring in genvm_common symbols so log_info! is available) at the top of
the file and extend the validation logic inside Config::validate to check that
self.registry_dir is not empty alongside self.cache_dir and self.runners_dir,
returning a bail! error similar to the existing messages if it is empty; keep
existing checks for modules.llm.address and modules.web.address intact.
I have added a high-precision execution timer in executor/src/lib.rs using std::time::Instant. This allows the GenVM to log exact execution time in microseconds for every Intelligent Contract call. This is a critical tool for developers to benchmark and optimize their contracts.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.