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

perf: Reduce tracing related allocations #479

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Mar 22, 2020

Now that tracing has been added to netcore I did a quick profile over the usual DataAccessPerformance benchmark app and investigated a few new hot allocation sources.

  • ActivityCorrelator was creating a new copy of the current activity on every call. I've made the class effectively immutable so the current instance can be returned every time without danger and change the Next() implementation to correctly generate the next in sequence as before.
  • TraceString() was being called unconditionally to pass into a method which wasn't going to use it. It's expensive so I added the check before the call, this means there are now two check but that should take less time than required for all the information generation and formatting.
  • TraceString was passing a lot of bools in a params object array which causes them to be boxed, I simply did a ternary check and passed in the preallocated string version instead.

@cheenamalhotra
Copy link
Member

cheenamalhotra commented Mar 23, 2020

Hi @Wraith2

Could you please update the same in NetFx project? We don't want to break consistency between the two if possible.

Edit: #483 created for the same.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Mar 23, 2020

Could you please update the same in NetFx project? We don't want to break consistency between the two if possible.

I don't usually port my changes to netfx for a few reasons.

  • I don't want to try and do everything twice and there are a lot of differences between the two codebases.
  • netfx is legacy at this point with netcore being net5 this year.
  • my hope/expectation was that the codebases would begin to merge so that any perf improvements were picked up by everyone equally. I expected the netcore codebase to be the better of the two most of the time for this effort.

@Wraith2 Wraith2 deleted the perf-tracing branch March 23, 2020 20:33
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