Skip to content
Merged
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
18 changes: 14 additions & 4 deletions pkg/sql/conn_executor_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4456,15 +4456,25 @@ func (ex *connExecutor) execWithProfiling(
}
// Compute fingerprint ID here since ih.Setup hasn't been called yet.
fingerprintID := appstatspb.ConstructStatementFingerprintID(
stmtNoConstants, ex.implicitTxn(), ex.sessionData().Database)
pprofutil.Do(ctx, func(ctx context.Context) {
err = op(ctx)
},
stmtNoConstants, ex.implicitTxn(), ex.sessionData().Database,
)
labels := make([]string, 0, 12)
labels = append(labels, []string{
workloadid.ProfileTag, sqlstatsutil.EncodeStmtFingerprintIDToString(fingerprintID),
"appname", ex.sessionData().ApplicationName,
"addr", remoteAddr,
"stmt.tag", ast.StatementTag(),
"stmt.no.constants", stmtNoConstants,
}...)
if opName, ok := GetInternalOpName(ctx); ok {
labels = append(labels, "opname", opName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I realized we can pre-allocate and extra slot in the []string to avoid the extra allocation on append, but probably not worth it given that is is within the profiling code path only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I also thought about this initially and had the same reasoning (slow path anyway) for not doing that. But given you mentioned it too and it's easy enough to avoid, done.

}
pprofutil.Do(
ctx,
func(ctx context.Context) {
err = op(ctx)
},
labels...,
)
} else {
err = op(ctx)
Expand Down
Loading