Home Dashboard Directory Help

KeyedCollection binary serialization performance is poor by JocularJoe


Status: 

Closed
 as Won't Fix Help for as Won't Fix


4
0
Sign in
to vote
Type: Bug
ID: 302290
Opened: 10/3/2007 10:25:55 AM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

A KeyedCollection contains both a list and a dictionary with the same items, and serializes both. Tests show that this takes almost twice as long as it needs to and results in a serialization stream that is 30% bigger.

To avoid this, the private field "private Dictionary<TKey, TItem> dict;" ought to be marked with the NonSerialized attribute.

As a consequence, a few members (Contains, AddKey, ContainsItem, Item) will need code
added to recreate the dictionary if it does not exist (following deserialization), something like:

if ((dict == null) && (this.keyCount >= this.threshold))
{
    this.CreateDictionary();
}
Details
Sign in to post a comment.
Posted by Microsoft on 12/10/2010 at 4:09 PM
Thanks again for taking the time to report this. Unfortunately, we won't be able to get to this for the next release of .NET, so I'm resolving this as Won't Fix.

Regards,

Justin Van Patten
Program Manager
Common Language Runtime
Posted by Microsoft on 2/26/2010 at 3:09 PM
In response to Mat's question in the comments, this issue was not addressed in .NET Framework 4. It's still on our radar for the next major release, but will have to be prioritized against other potential features.

Thanks,
Melitta
Base Class Libraries
Posted by Matthew Steeples on 1/19/2010 at 1:36 AM
Did this get considered for the release of .net 4.0?
Posted by Microsoft on 10/28/2007 at 6:01 PM
Hi Joe,
Thank you for the excellent suggestion. This is certainly an valid option for reducing the serialized size of the KeyedCollection; the dictionary would need to be re-generated on deserialization but this would need to significant size savings as you described. We're considering this change as an improvement for the next major version of the runtime.

Thanks again!
Kim Hamilton
Base Class Libraries
Posted by Microsoft on 10/4/2007 at 2:19 AM
Thanks for your feedback.

We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 10/3/2007 at 8:11 PM
Thank you for your feedback. We are currently investigating. The investigation process normally takes 7-14 days. If this issue is urgent, please contact support directly (see http://support.microsoft.com).

If at any time your issue is closed unsatisfactorily, you may edit your issue via Connect and change the status to “Active.”

Thank you,
Visual Studio Product Team
Sign in to post a workaround.