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

[NetFx] Perf: Reduce tracing related allocations from TVP write #564

Merged
merged 1 commit into from
May 15, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -9689,6 +9689,8 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo

// Stream out parameters
SqlParameter[] parameters = rpcext.parameters;

bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn();

for (int i = (ii == startRpc) ? startParam : 0; i < parameters.Length; i++)
{
Expand Down Expand Up @@ -9723,7 +9725,7 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo

if (mt.IsNewKatmaiType)
{
WriteSmiParameter(param, i, 0 != (rpcext.paramoptions[i] & TdsEnums.RPC_PARAM_DEFAULT), stateObj);
WriteSmiParameter(param, i, 0 != (rpcext.paramoptions[i] & TdsEnums.RPC_PARAM_DEFAULT), stateObj, isAdvancedTraceOn);
continue;
}

Expand Down Expand Up @@ -10456,7 +10458,7 @@ private void WriteParameterName(string parameterName, TdsParserStateObject state
}

private static readonly IEnumerable<SqlDataRecord> __tvpEmptyValue = new List<SqlDataRecord>().AsReadOnly();
private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj)
private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj, bool advancedTraceIsOn)
{
//
// Determine Metadata
Expand Down Expand Up @@ -10508,7 +10510,10 @@ private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefa
}

var sendDefaultValue = sendDefault ? 1 : 0;
SqlClientEventSource.Log.AdvancedTraceEvent("<sc.TdsParser.WriteSmiParameter|ADV> {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3));
if (advancedTraceIsOn)
{
SqlClientEventSource.Log.AdvancedTraceEvent("<sc.TdsParser.WriteSmiParameter|ADV> {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3));
}

//
// Write parameter metadata
Expand Down