Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] Add a Log execution event, created with the log syscall #1396

Merged
merged 1 commit into from
Jan 6, 2023

Conversation

anorth
Copy link
Member

@anorth anorth commented Jan 5, 2023

I am attempting to improve instrumentation to support analysis of gas charges across spans of code. See #1397.

This PR adds a Log execution event to the trace format. A log event is recorded when the log syscall is invoked. The log event carries a single String message.

A string is the most basic payload to carry here, so I think the right place to start. Some structure may be encoded into strings (for subsequent offline analysis). We could consider adding some kind of key/value pair metadata, but I suggest we defer until observed usage justifies it.

Note that the GasCharge event's name is a Cow<'static, str>. I presume this is because the same literal name is expected to be used frequently and this type will lead to meaningful optimisation. I'm not sure that that's appropriate for the Log event, if it would rule out dynamically constructed messages.

This PR is against the release/v2 branch, because I am analysing the built-in actors that are not yet using fvm v3. I intend to forward-port it when stable.

@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2023

Codecov Report

Merging #1396 (69718f3) into release/v2 (2b625d2) will decrease coverage by 0.92%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           release/v2    #1396      +/-   ##
==============================================
- Coverage       51.18%   50.25%   -0.93%     
==============================================
  Files             126      126              
  Lines           10267    10458     +191     
==============================================
+ Hits             5255     5256       +1     
- Misses           5012     5202     +190     
Impacted Files Coverage Δ
fvm/src/call_manager/default.rs 0.00% <0.00%> (ø)
fvm/src/call_manager/mod.rs 15.78% <0.00%> (-4.22%) ⬇️
fvm/src/kernel/default.rs 13.15% <0.00%> (-2.60%) ⬇️
fvm/src/trace/mod.rs 0.00% <ø> (ø)
sdk/src/send.rs 0.00% <0.00%> (ø)
ipld/amt/src/node.rs 86.82% <0.00%> (+0.25%) ⬆️
ipld/encoding/src/cbor.rs 7.69% <0.00%> (+2.33%) ⬆️

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits but LGTM.

@@ -121,6 +121,12 @@ pub trait CallManager: 'static {
self.gas_tracker_mut().apply_charge(charge)?;
Ok(())
}

/// Whether tracing is requested.
fn tracing(&self) -> bool;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to just call call_manager.machine().context().tracing? It's long, but we only call this once.

Otherwise, I'd provide a default implementation that delegates to self.machine().context().tracing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the default implementation, thanks. There are additionally 3 internal calls to this, and the many hops to get there adds coupling through those objects at more places.

@Stebalien Stebalien merged commit 8e9973f into release/v2 Jan 6, 2023
@Stebalien Stebalien deleted the anorth/tracing branch January 6, 2023 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants