<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:42:36 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-2456] Use less memory without scope capturing</title>
                <link>https://jira.mongodb.org/browse/CSHARP-2456</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/b473de06f9bf3587b3a00f52ba2678d9aed71d74/src/MongoDB.Bson/IO/JsonWriter.cs#L708&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;JsonWriter.EscapedString implementation&#160;&lt;/a&gt;uses anonymous function that touches instance private method -&#160;forces compiler to capture scope with &apos;this&apos; for each =\&lt;/p&gt;

&lt;p&gt;We &lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/349&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;can switch from .All LINQ to hand written method&lt;/a&gt;&#160;to avoid object allocation each time method called (super-often).&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</description>
                <environment>Any, its about C# driver doing same, but faster :)</environment>
        <key id="654280">CSHARP-2456</key>
            <summary>Use less memory without scope capturing</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="nik">Nikolay Mitikov</reporter>
                        <labels>
                    </labels>
                <created>Fri, 14 Dec 2018 05:46:31 +0000</created>
                <updated>Tue, 6 Jun 2023 15:29:52 +0000</updated>
                                            <version>2.7.2</version>
                                                    <component>Json</component>
                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2094018" author="nik" created="Tue, 18 Dec 2018 04:06:17 +0000"  >&lt;p&gt;Hi @&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ian.whalen&quot; class=&quot;user-hover&quot; rel=&quot;ian.whalen&quot;&gt;ian.whalen&lt;/a&gt;, yep, we can!&lt;/p&gt;

&lt;p&gt;I see few options for data collection&#160;during any Json serialization/deserialization -&#160;measure either memory traffic (volume of allocated objects), or check memory snapshots&#160;&lt;/p&gt;

&lt;p&gt;1) Launch &lt;a href=&quot;https://github.com/Microsoft/perfview&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;PerfView&lt;/a&gt;&#160;session with defaults and inspect &apos;GC Heap Alloc Ignore Free&apos; memory views - how many objects were allocated&lt;/p&gt;

&lt;p&gt;2) Collect memory snapshot at random time and perform &apos;!dumpheap -stat&apos; to locate objects living in heap&lt;/p&gt;

&lt;p&gt;Alternatively we can mimic both codes in &lt;a href=&quot;https://github.com/dotnet/BenchmarkDotNet&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Benchmark.NET tests&lt;/a&gt;&#160;with &lt;a href=&quot;https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/Attributes/MemoryDiagnoserAttribute.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Memory Diagnoser on.&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I my case it was around 1M objects created in the heap -&amp;gt; ~24 MB of useless pressure captured at a moment in time.&lt;/p&gt;

&lt;p&gt;The perf. win is small, but still better than no win.&lt;/p&gt;</comment>
                            <comment id="2093383" author="ian@10gen.com" created="Mon, 17 Dec 2018 20:19:57 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=nik&quot; class=&quot;user-hover&quot; rel=&quot;nik&quot;&gt;nik&lt;/a&gt; thanks for opening the ticket here. Do you have any measurements you can add to highlight the benefit we might see here?&lt;/p&gt;</comment>
                            <comment id="2090903" author="ian@10gen.com" created="Fri, 14 Dec 2018 14:44:23 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/pull/349&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/pull/349&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="638898">CSHARP-2442</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hu6f6v:</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>