zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.96k stars 743 forks source link

Huge allocations in the NetMQ.Core.Transports.ByteArraySegment #979

Open Svisstack opened 3 years ago

Svisstack commented 3 years ago

Environment

NetMQ Version:   4.0.1.6 
Operating System: Windows
.NET Version: .NET 5.0 

Expected behaviour

Have a possibility to not allocate on the GC or have a reasonable workaround to eliminate allocations on the GC.

Actual behaviour

Visible allocations in the NetMQ.Core.Transports.ByteArraySegment from https://github.com/zeromq/netmq/blob/master/src/NetMQ/Core/Transports/V2Decoder.cs#L85

Steps to reproduce the behaviour

Run Pub -> Sub pattern and profile the Subscriber.

Looking for ideas why this is happening and how this could be fixed.

image

drewnoakes commented 3 years ago

ByteArraySegment could probably be a readonly struct with a little refactoring.