-
Type: Task
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Class deserializer has many work with reflection , excess loop checks, set values to properties produce boxing
Collection deserialization create excess list instead of return the ready one and again - REFLECTION....
I solved these problems:
https://github.com/mongodb/mongo-csharp-driver/pull/871
- optimized create instance - without reflection
- optimized set values to properties- without reflection, boxing, interface virtualization impact (for Deserialize Call)
- optimized collection deserialization- in most cases we can just return prepared List, in some other cases - removed reflection
- cache IsReadonly
- dont call SetRequiredFields if required fields does not exists (flag of required fields exist was cached)
- seporate deserialization of classes with default constructor and classes with creatorMap (to get rid of null checks)
- add generic BsonMemberMap for some optimizations above
- fix one test , that used local culture in Parse method and failed
var expectedResult = decimal.Parse(expectedResultString, CultureInfo.InvariantCulture); – pass culture here
Links:
1) PR: https://github.com/mongodb/mongo-csharp-driver/pull/871
2) Test Project: https://github.com/troepolik/testMongoDBPerformance
just set reference to BSON project, sure you set release mode and run, and press to repeate several times to see statistics, then switch to my optimized project.
Sugestion: press repeat in moment when CPU% is low.
- related to
-
CSHARP-4306 Performance optimization for class and collections deserialization
- Backlog