<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:47:50 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-4306] Performance optimization for class and collections deserialization</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4306</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Class deserializer has many work with reflection, set properies produces boxing, has many loop checks and so on...&lt;/p&gt;

&lt;p&gt;Collection deserializer always create new list after deserialization insead of return ready one. And again - REFLECTION.&lt;/p&gt;

&lt;p&gt;I solve this problem and get about 35% perf up in my cases with huge dto objects:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/871&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/pull/871&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;optimized create instance - without reflection&lt;/li&gt;
	&lt;li&gt;optimized set values to properties- without reflection, boxing, interface virtualization impact (for Deserialize Call)&lt;/li&gt;
	&lt;li&gt;optimized collection deserialization- in most cases we can just return prepared List, in some other cases - removed reflection&lt;/li&gt;
	&lt;li&gt;cache IsReadonly&lt;/li&gt;
	&lt;li&gt;dont call SetRequiredFields if required fields does not exists (flag of required fields exist was cached)&lt;/li&gt;
	&lt;li&gt;seporate deserialization of classes with default constructor and classes with creatorMap (to get rid of null checks)&lt;/li&gt;
	&lt;li&gt;add generic BsonMemberMap for some optimizations above&lt;/li&gt;
	&lt;li&gt;fix one test , that used local culture in Parse method and failed&lt;br/&gt;
var expectedResult = decimal.Parse(expectedResultString, CultureInfo.InvariantCulture); &amp;#8211; pass culture here&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Links:&lt;/p&gt;

&lt;p&gt;1) PR: &lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/871&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/pull/871&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Test Project: &lt;a href=&quot;https://github.com/troepolik/testMongoDBPerformance&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/troepolik/testMongoDBPerformance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&#160;&lt;/p&gt;

&lt;p&gt;Sugestion: press repeat in moment when CPU% is low.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2128292">CSHARP-4306</key>
            <summary>Performance optimization for class and collections deserialization</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="aleksei.troepolskii@altenar.com">Aleksei Troepolskii</reporter>
                        <labels>
                    </labels>
                <created>Fri, 2 Sep 2022 12:34:45 +0000</created>
                <updated>Thu, 8 Jun 2023 15:30:10 +0000</updated>
                                                                            <component>BSON</component>
                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4907246" author="JIRAUSER1257742" created="Mon, 17 Oct 2022 15:23:59 +0000"  >&lt;p&gt;Hello &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=aleksei.troepolskii%40altenar.com&quot; class=&quot;user-hover&quot; rel=&quot;aleksei.troepolskii@altenar.com&quot;&gt;aleksei.troepolskii@altenar.com&lt;/a&gt; , thank you for your research and the PR.&lt;br/&gt;
The ideas around avoiding reflection and caching some of the data are great, as well as other smaller performance optimizations.&lt;br/&gt;
We are going to consider those ideas as part of a general serialization improvement effort &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-3230&quot; title=&quot;Improve Serialization&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-3230&quot;&gt;CSHARP-3230&lt;/a&gt;.&lt;br/&gt;
Please follow this ticket and &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-3230&quot; title=&quot;Improve Serialization&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-3230&quot;&gt;CSHARP-3230&lt;/a&gt; epic for any further updates.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2128297">CSHARP-4307</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2128320">CSHARP-4308</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>CSHARP-3230</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0rji8:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>