[CSHARP-1111] Reduce the number of serialization contexts that must be created Created: 20/Nov/14 Updated: 02/Apr/15 Resolved: 11/Dec/14 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | None |
| Fix Version/s: | 2.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Robert Stam | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
In our current 2.0 design, a new serialization context must be created every time we descend one level in the hierarchy of the document being serialized or deserialized. Most of the time, the only thing that is changing is the nominal type. Perhaps it would be better to move the nominal type out of the serialization context and back as a parameter of the Serialize/Deserialize methods, which would allow us to use the same context over and over, thus reducing GC pressure. |
| Comments |
| Comment by Robert Stam [ 11/Dec/14 ] |
|
There were more values besides just the nominalType that needed to be moved out of the serialization context, so we introduced Args classes to hold them. In summary: BsonDeserializationContext/BsonSerializationContext hold values that remain constant all the way down the call stack during serialization (although in some rare cases we might modify the context part way down) BsonDeserializationArgs/BsonSerializationArgs hold values that only apply to one level of the call stack. The Args classes are small structs so creating them does not increase GC pressure. |
| Comment by Githook User [ 11/Dec/14 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 11/Dec/14 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |