Skip to content

Conversation

@noahfalk
Copy link
Member

@noahfalk noahfalk commented Apr 8, 2025

  • Re-enabling support for parsing format V6 and re-enabling the tests
  • Removed support for ancient netperf format version 1 and 2 that were only used during .NET Core 2.0 (not even 2.1).
  • The implementation of the Nettrace reader was doing a bunch of pinning because the TraceEvent internal model of events uses unmanaged pointers, however the pinning was creating bad GC performance. TraceEvent builds for .NET standard so we don't have guaranteed access to the pinned heap and I didn't want to start doing lots of copying and/or managing pools of pinned arrays. Instead I switched the stream reading over to using spans backed by native heap allocations and explicit block lifetime tracking. As a side benefit it also brings the V3-5 block iteration code a bit closer to the V6 block iteration and removed all the dependencies on the existing FastSerialization library.
  • Add MinSupportedVersion and MaxSupportedVersion to the UnsupportedVersionException

@wiktork - This may fix the GC issues you were seeing in dotnet-monitor
@karpinsn - Exception improvements should help with version error messages in Dev18

@mdh1418, @brianrob, @lateralusX, @beaubelgrave - aside from turning back on V6 support hopefully the behavior should be nearly identical to before despite all the code churn in there.

…rtedVersionException

- Re-enabling support for parsing format V6 and re-enabling the tests
- Removed support for ancient netperf format version 1 and 2 that were only used during .NET Core 2.0 (not even 2.1).
- The implementation of the Nettrace reader was doing a bunch of pinning because the TraceEvent internal model of events uses unmanaged pointers, however the pinning was creating bad GC performance.
  TraceEvent builds for .NET standard so we don't have guaranteed access to the pinned heap and I didn't want to start doing lots of copying and/or managing pools of pinned arrays. Instead I switched the
  stream reading over to using spans backed by native heap allocations and explicit block lifetime tracking. As a side benefit it also brings the V3-5 block iteration code a bit closer to the V6 block iteration and
  removed all the dependencies on the existing FastSerialization library.
- Add MinSupportedVersion and MaxSupportedVersion to the UnsupportedVersionException
@noahfalk noahfalk requested a review from brianrob as a code owner April 8, 2025 06:27
@noahfalk noahfalk changed the title Change format version support, eliminate pinning, and improve UnsupportedVersionException Change NetTrace format version support, eliminate pinning, and improve UnsupportedVersionException Apr 8, 2025
Copy link
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

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

Thanks @noahfalk for putting this together! A few comments/questions below.

- Removed some V1_V2 support code that I missed before
- Added comments referencing the block header format and why we have a duplicate FastSerialization tag enum
- Pruned unneeded using statements
- Switched from EndOfStreamException to FormatException so that we consistently use FormatException for all format issues
- Removed StreamExtensions.ReadAtLeast which was dead code
- Add tests for incomplete stream handling and verifying StreamExtensions.Read is implemented as expected for different platforms
@noahfalk
Copy link
Member Author

noahfalk commented Apr 9, 2025

Thanks for the feedback @brianrob! Hopefully the latest commit addresses all of it.


internal FixedBuffer(int length)
{
_pointer = Marshal.AllocHGlobal(length);
Copy link
Member

Choose a reason for hiding this comment

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

Would NativeMemory be more appropriate here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unforetunately TraceEvent targets .NET Standard 2.0 and NativeMemory was first supported in .NET 6 so it isn't available.

Copy link
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @noahfalk!

@brianrob brianrob merged commit dc5e340 into microsoft:main Apr 9, 2025
5 checks passed
wiktork added a commit to dotnet/diagnostics that referenced this pull request May 5, 2025
Code updates are based on
microsoft/perfview#2121

Would like to incorporate
microsoft/perfview#2180 into dotnet-monitor, to
potentially improve memory usage.

~~Test failures are most likely due to changes from
microsoft/perfview#2170 Fixed with newest
version
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.

3 participants