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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ runCatchup(CommandLineArgs const& args)
int result;
{
auto app = Application::create(clock, config, inMemory);
app->applyCfgCommands();
auto const& ham = app->getHistoryArchiveManager();
auto archivePtr = ham.getHistoryArchive(archive);
if (iequals(archive, "any"))
Expand Down
8 changes: 8 additions & 0 deletions src/transactions/InvokeHostFunctionOpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,14 @@ InvokeHostFunctionOpFrame::doApply(Application& app, AbstractLedgerTxn& ltx,
metrics.mCpuInsnExclVm = out.cpu_insns_excluding_vm_instantiation;
metrics.mInvokeTimeNsecsExclVm =
out.time_nsecs_excluding_vm_instantiation;

CLOG_TRACE(Tx, "invokeTimeNsecs: {}, cpuInsn: {}, ratio: {}",
metrics.mInvokeTimeNsecs, metrics.mCpuInsn,
(float)metrics.mInvokeTimeNsecs / (float)metrics.mCpuInsn);
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?

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

if (!out.success)
{
maybePopulateDiagnosticEvents(appConfig, out, metrics);
Expand Down
6 changes: 6 additions & 0 deletions src/transactions/TransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,12 @@ TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx,

ok = applyOperations(signatureChecker, app, ltx, meta,
sorobanBasePrngSeed);

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

}
}
return ok;
}
Expand Down
Loading