<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:55:45 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>[JAVA-1880] Higher memory allocation rate for write commands than write protocol</title>
                <link>https://jira.mongodb.org/browse/JAVA-1880</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;&lt;b&gt;TL;DR&lt;/b&gt;&lt;br/&gt;
In the 2.13.x driver, the write command paths do not leverage the &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/r2.13.2/src/main/com/mongodb/Mongo.java#L647-L654&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;Mongo&lt;/tt&gt; client&apos;s &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt; pool&lt;/a&gt; while the write protocol codepaths do.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Details&lt;/b&gt;&lt;br/&gt;
The &lt;tt&gt;Mongo&lt;/tt&gt; client instance maintains a &lt;tt&gt;_bufferPool&lt;/tt&gt; of 1000 &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt;&apos;s. &lt;/p&gt;

&lt;p&gt;&lt;b&gt;For write protocol operations&lt;/b&gt;&lt;br/&gt;
When talking to a &amp;lt;=2.4 mongod, or using UNACKNOWLEDGED writes to a &amp;gt;=2.6 mongod, this &lt;tt&gt;_bufferPool&lt;/tt&gt; is used to provide a &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt; for both encoding the write as well as reading the response (&lt;tt&gt;OutMessage&lt;/tt&gt;).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;For write command operations&lt;/b&gt;&lt;br/&gt;
Sending the op to the mongod (&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/r2.13.2/src/main/com/mongodb/DBCollectionImpl.java#L518&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;sendWriteCommandMessage()&lt;/tt&gt;&lt;/a&gt;) and receiving the response (&lt;tt&gt;receiveWriteCommandMessage(()&lt;/tt&gt; creating &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/r2.13.2/src/main/com/mongodb/DBCollectionImpl.java#L532&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;a new DefaultDBDecoder&lt;/a&gt;) each create in a new unpooled &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;The consequence is that while &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt; &lt;em&gt;does&lt;/em&gt; contains a static pool of &quot;extra&quot; byte arrays which are used for growing, each &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt; instance still has a minimum 32KB allocation for the &lt;tt&gt;_mine&lt;/tt&gt; and &lt;tt&gt;_chars&lt;/tt&gt; buffers &amp;#8211; a nontrivial amount per operation.&lt;/p&gt;

&lt;p&gt;Consider the following flight recorder sample:&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/attachment/80470/80470_allocation_new_tlab.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The above shows for allocations in TLAB by class, &lt;tt&gt;char[]&lt;/tt&gt; and &lt;tt&gt;byte[]&lt;/tt&gt; contribute to 50%+ of all allocation pressure. And for this application, 43% of the &lt;tt&gt;char[]&lt;/tt&gt; allocations are from &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt; on the write command paths. (Not shown above, but 83% of &lt;tt&gt;byte[]&lt;/tt&gt; is &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt;.) &lt;/p&gt;

&lt;p&gt;Again for this write-heavy application anyway, outside TLAB pressure shows even higher pressure:&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/attachment/80471/80471_allocation_outside_tlab.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Here we see the &lt;tt&gt;byte[]&lt;/tt&gt; and &lt;tt&gt;char[]&lt;/tt&gt; combine to ~93% of all allocation pressure, and the majority of each again as &lt;tt&gt;PoolOutputBuffer&lt;/tt&gt; on write command paths (83% and 93%, respectively).&lt;/p&gt;</description>
                <environment>Driver 2.13.2&lt;br/&gt;
Oracle JDK 1.8</environment>
        <key id="214862">JAVA-1880</key>
            <summary>Higher memory allocation rate for write commands than write protocol</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="john.morales@mongodb.com">John Morales</reporter>
                        <labels>
                    </labels>
                <created>Sat, 4 Jul 2015 20:48:18 +0000</created>
                <updated>Tue, 16 Aug 2016 13:27:14 +0000</updated>
                            <resolved>Thu, 9 Jul 2015 16:15:41 +0000</resolved>
                                    <version>2.12.5</version>
                    <version>2.13.2</version>
                                    <fixVersion>2.13.3</fixVersion>
                    <fixVersion>2.14.0</fixVersion>
                                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="962254" author="xgen-internal-githook" created="Thu, 9 Jul 2015 16:09:01 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;jyemin&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;}
&lt;p&gt;Message: For write commands, use buffer pool for encoding and the DBPort&apos;s decoder for decoding.  By using pooled buffers instead of short-lived ones,&lt;br/&gt;
memory pressure is reduced.&lt;/p&gt;

&lt;p&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1880&quot; title=&quot;Higher memory allocation rate for write commands than write protocol&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1880&quot;&gt;&lt;del&gt;JAVA-1880&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: 2.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/3020e7bd3c3582051c13259bc2c06895b8afc96e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/3020e7bd3c3582051c13259bc2c06895b8afc96e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="962253" author="xgen-internal-githook" created="Thu, 9 Jul 2015 16:08:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;jyemin&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;}
&lt;p&gt;Message: For write commands, use buffer pool for encoding and the DBPort&apos;s decoder for decoding.  By using pooled buffers instead of short-lived ones,&lt;br/&gt;
memory pressure is reduced.&lt;/p&gt;

&lt;p&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1880&quot; title=&quot;Higher memory allocation rate for write commands than write protocol&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1880&quot;&gt;&lt;del&gt;JAVA-1880&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: 2.13.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/1e81245457cc29a6b35f34c9bdfcb0d74a5d657c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/1e81245457cc29a6b35f34c9bdfcb0d74a5d657c&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="80470" name="allocation_new_tlab.png" size="281556" author="john.morales@mongodb.com" created="Sat, 4 Jul 2015 20:48:18 +0000"/>
                            <attachment id="80471" name="allocation_outside_tlab.png" size="233368" author="john.morales@mongodb.com" created="Sat, 4 Jul 2015 20:48:18 +0000"/>
                    </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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrejqn:</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>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="522">Java Sprint 20</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>