[Mono-list] Mono and IO Performance

Julien julien.lavigne at gmail.com
Mon Mar 28 12:54:17 EDT 2011


I’m comparing.Net and mono runtimes for server applications that are socket
bound. The performance penalty for mono is significant and I would like some
advice from more experienced users.

My scenario is the following : 
I’m trying to dequeue messages from a socket and dispatch them locally. On
windows/.net, I can handle between 8k and 9k msg/second in release mode. The
same application under windows/mono (with—gc=sgen) handles between 1.5k and
3.5K msg/second. Under ubuntu/mono, it handles between 2K and 4k msg/second. 

In order to find the bottleneck, I did a profiling under linux. Here are the
GC Summary : 
	GC resizes: 0
	Max heap size: 0
	Object moves: 108499
	Gen0 collections: 134, max time: 10185us, total time: 257995us, average:
1925us
	Gen1 collections: 4, max time: 8366us, total time: 27318us, average: 6829us
	GC handles weak: created: 35, destroyed: 0, max: 35
	GC handles normal: created: 2, destroyed: 0, max: 2

And the first few lines of the method call summary, sorted by self :
414671   414671      99881 (wrapper managed-to-native)
System.Threading.Monitor:Monitor_wait (object,int)
  397184   396993      76558 (wrapper managed-to-native)
System.IO.InotifyWatcher:ReadFromFD (intptr,byte[],intptr)
  275720   275720         11 (wrapper managed-to-native)
System.Net.Sockets.Socket:Receive_internal
(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)
  114162   114162         26 (wrapper managed-to-native)
System.IO.MonoIO:Read (intptr,byte[],int,int,System.IO.MonoIOError&)
   42467    16991    5700212 System.IO.MemoryStream:Write (byte[],int,int)
   15231    15231    4803054 (wrapper managed-to-native)
System.Array:GetValueImpl (System.Array,int)
   14978    14978   15601077
System.IO.MemoryStream:CheckIfClosedThrowDisposed ()
   20583    13663    7000528 System.Buffer:BlockCopy
(System.Array,int,System.Array,int,int)
   11961    11961    4660789 (wrapper managed-to-native)
object:__icall_wrapper_mono_array_new_specific (intptr,int)
   49573    11374    2400012 System.Array:slow_swapper (int,int)
   13790     9375    4600196 System.IO.MemoryStream:WriteByte (byte)
   22632     8842    4600194 System.IO.BinaryWriter:Write (byte)
   14220     8500    3000283 System.Array:GetUpperBound (int)
    8454     8454    3765335 (wrapper managed-to-native)
object:__icall_wrapper_mono_object_new_specific (intptr)
    6919     6919    7000570 (wrapper managed-to-native)
System.Buffer:BlockCopyInternal (System.Array,int,System.Array,int,int)
   25695     6885    2400038 System.Array:GetValue (int)
    9661     6447    3300992
System.Collections.Generic.InternalStringComparer:GetHashCode (string)
   48406     5797    1200017
org.apache.qpid.transport.codec.AbstractEncoder:WriteStr8 (string)
    8064     5515    2700095 System.Diagnostics.Debug:Assert (bool)
    5354     5354     100028 (wrapper managed-to-native)
System.Threading.Monitor:Monitor_pulse_all (object)
    7354     4946    2500198 System.IO.MemoryStream:Seek
(long,System.IO.SeekOrigin)
    4746     4746    4801285 (wrapper managed-to-native)
System.Array:SetValueImpl (System.Array,object,int)
   52871     4740     300021
org.apache.qpid.transport.network.Disassembler:Frame
(byte,byte,byte,int,int,System.IO.MemoryStream)
   22183     4638    1200060
org.apache.qpid.transport.codec.MSEncoder:WriteUint16 (int)
    6914     4626    2400000 org.apache.qpid.client.Message:get_Header ()
   15174     4350    1400022
org.apache.qpid.transport.codec.MSEncoder:WriteUint8 (int16)
   59094     4246     600003 System.Array:Reverse (System.Array,int,int)
  145864     4193     100002
org.apache.qpid.transport.codec.AbstractEncoder:WriteMapEntries
(System.Collections.Generic.Dictionary`2<string, object>)

Most of it seems to be Allocations/IO/Array manipulation.


Are there any optimisations worth pursuing at my level? (mono options?) Or
any way to target more precisely the differences between .Net/mono? 


Best regards,

Julien




--
View this message in context: http://mono.1490590.n4.nabble.com/Mono-and-IO-Performance-tp3412393p3412393.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list