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

Add some trace logging for Soroban #4305

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jayz22
Copy link
Contributor

@jayz22 jayz22 commented May 7, 2024

Description

Some useful trace logging improvements when I was troubleshooting spikes in the Soroban (time cpu ratio) metrics.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copy link
Contributor

@SirTyson SirTyson left a comment

Choose a reason for hiding this comment

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

LGTM, minor nitpicks

if (isSoroban())
{
CLOG_TRACE(Tx, "Soroban transaction meta: {}",
xdr::xdr_to_string(meta.getXDR(), "meta"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: use xdrToCerealString

CLOG_TRACE(Tx, "(excl VM) invokeTimeNsecs: {}, cpuInsn: {}, ratio: {}",
metrics.mInvokeTimeNsecsExclVm, metrics.mCpuInsnExclVm,
(float)metrics.mInvokeTimeNsecsExclVm /
(float)metrics.mCpuInsnExclVm);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: C++ Style cast. We also only need to cast one of the numerator or denominator. Finally since this is just logs, why not use double for extra precision?

CLOG_TRACE(Tx, "(excl VM) invokeTimeNsecs: {}, cpuInsn: {}, ratio: {}",
metrics.mInvokeTimeNsecsExclVm, metrics.mCpuInsnExclVm,
(float)metrics.mInvokeTimeNsecsExclVm /
(float)metrics.mCpuInsnExclVm);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to protect against divide by zero here? Something like

metrics.mCpuInsnExclVm ? metrics.mInvokeTimeNsecsExclVm / (float)metrics.mCpuInsnExclVm : 0f

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.

2 participants