> > Some time ago, we did some research about speeding up binary > > serialization for remoting and we found out that the .NET 1.x codebase was > > faster than the .NET 2.0 codebase. After profiling the code, it turned out > > that the generic dictionary objects were slowing things down. Replacing them > > with hashtables made it equal again (or .net 2.0 became slightly faster). > > Looking deeper into it, the GetObjectData routines differ. When I made a > > Dictionary class which had a similar GetObjectData routine as Hashtable, > > namely serializing the keys and values as object arrays, it was solved. > > Okay, good to know. If I ever need it, I'll time it myself :)
:). It's one of those gotcha's one will only run into when performance is critical. :). After a while you'll then realize that the whole binary formatter is dead slow and implement your own serialization classes (which write to a byte array, caching redundant objects etc.) and this whole issue is moot ;) (A bit offtopic perhaps, but see Simon Hewitt's articles on code project about this subject: http://www.codeproject.com/dotnet/FastSerializer.asp and http://www.codeproject.com/dotnet/OptimizingSerialization2.asp Once you dig into this, there's no end in sight apparently, but it's good to know for remoting users that there is a way to speed things up ;). We worked with Simon to get our remoting code as fast as possible and with compact block sizes. ) > > The Order of the items isn't important for hashtables/dictionaries, > as > > the order isn't defined: you can't pull the data out in a given order. > > Well, you can enumerate over the items, keys, and values (and do > CopyTo), and I guess one _could_ expect a deserialized Dictionary to > enumerate in the same order as the original one unless explicitly told > it isn't so. One could use the enumerator indeed, but if I add an item, is it always appended to the list? IMHO undefined. The Dictionary<T,U> docs say: "For purposes of enumeration, each item in the dictionary is treated as a KeyValuePair structure representing a value and its key. The order in which the items are returned is undefined." So it's undefined what order the items are returned. :) FB =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com