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

EventPipe: Remove Duplicate Buffer Copies in EventSource #8707

Closed
brianrob opened this issue Aug 4, 2017 · 2 comments
Closed

EventPipe: Remove Duplicate Buffer Copies in EventSource #8707

brianrob opened this issue Aug 4, 2017 · 2 comments
Assignees
Milestone

Comments

@brianrob
Copy link
Member

brianrob commented Aug 4, 2017

There is currently an extra buffer copy in the EventSource log path that we should remove.

This is the set of copies that occur:

  1. The strongly typed data is converted to "ETW" format, which is a list of pointers serialized argument blobs.
  2. In EventPipeEventProvider.EventWriteTransferWrapper, this data gets copied into a new buffer that is allocated on the managed heap and pinned. (See https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs#L83)
  3. The buffer in step 2 is copied byte for byte into the circular buffer (This call does the copy: https://github.com/dotnet/coreclr/blob/master/src/vm/eventpipe.cpp#L312)

We should get rid of the buffer copy in number 2 above, and just plumb an API down that takes the set of pointers to blobs and writes them directly into the circular buffer.

@nategraf
Copy link
Contributor

nategraf commented Aug 8, 2017

Searching the source code I find this to be the only place where EventPipeInternal::WriteEvent is called. Similarly EventPipe::WriteEvent (the cpp side) appears to only be called from EventPipeInternal::WriteEvent

Does that mean I can safely change the expected format of pData for these two functions as a way to eliminate the need for this buffer copy (to flatten the data), or should I create a new API in the cpp code which can take the unflattened data?

@brianrob
Copy link
Member Author

brianrob commented Aug 8, 2017

EventPipeInternal::WriteEvent is only called from the one place that you reference above. That's the managed --> native call from EventSource into the EventPipe. That's where we want to reduce buffer copies.

EventPipeInternal::WriteEvent is not the only caller of WriteEvent, but might be the only "searchable" caller if you search in GitHub. It is also called from code that is generated during the build. You can see the call in the script that generates the code here: https://github.com/dotnet/coreclr/blob/master/src/scripts/genEventPipe.py#L111. This is the script that generates the "FireEtw*" functions that call into the EventPipe.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants