<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:35 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-137] SimplePool._get() &quot;busy&quot; wait suffers under heavy load.</title>
                <link>https://jira.mongodb.org/browse/JAVA-137</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;After investigating an issue where a service was using 100% of available CPU yet not accomplishing much, I saw that most threads had the following at the top of the java stack trace:&lt;/p&gt;

&lt;p&gt;        at java.lang.Thread.sleep(Thread.java)&lt;br/&gt;
        at com.mongodb.util.ThreadUtil.sleep(ThreadUtil.java:37)&lt;br/&gt;
        at com.mongodb.util.SimplePool._get(SimplePool.java:162)&lt;br/&gt;
        at com.mongodb.util.SimplePool.get(SimplePool.java:106)&lt;br/&gt;
        at com.mongodb.util.SimplePool.get(SimplePool.java:95)&lt;br/&gt;
        at com.mongodb.ByteEncoder.get(ByteEncoder.java:66)&lt;br/&gt;
        at com.mongodb.DBMessage.&amp;lt;init&amp;gt;(DBMessage.java:52)&lt;br/&gt;
        at com.mongodb.DBApiLayer$MyCollection.find(DBApiLayer.java:282)&lt;br/&gt;
        at com.mongodb.DBCursor._check(DBCursor.java:253)&lt;br/&gt;
        at com.mongodb.DBCursor._hasNext(DBCursor.java:374)&lt;br/&gt;
        at com.mongodb.DBCursor.hasNext(DBCursor.java:399)&lt;/p&gt;

&lt;p&gt;Our software was running with a few (maybe ~2x) more threads than connections, and was doing a fair mix of read and write in mongo. Our reads are typically cursoring over many objects. When we write to mongo we always call resetError() and getLastError() to verify the write.&lt;/p&gt;

&lt;p&gt;I read through the 1.4 java driver code and saw that for every DBMessage created (in our case, many thousands per second), the thread enters what I consider a busy wait (despite a 15 millisecond Thread.sleep()) while it waits for a ByteEncoder. This ended up accounting for a significant percentage of our overall CPU load.&lt;/p&gt;

&lt;p&gt;Have you considered using wait() and notify()? Or different ByteEncoder creation/allocation strategies (such as ThreadLocal)?&lt;/p&gt;</description>
                <environment>mongo java driver 1.4&lt;br/&gt;
mongo server 1.4.2&lt;br/&gt;
&lt;br/&gt;
default settings for max connections, etc.</environment>
        <key id="12533">JAVA-137</key>
            <summary>SimplePool._get() &quot;busy&quot; wait suffers under heavy load.</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="steven.m.reed@gmail.com">Steve Reed</reporter>
                        <labels>
                    </labels>
                <created>Fri, 23 Jul 2010 22:54:10 +0000</created>
                <updated>Sat, 24 Jul 2010 01:22:53 +0000</updated>
                            <resolved>Sat, 24 Jul 2010 01:22:53 +0000</resolved>
                                    <version>1.4</version>
                                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="16101" author="eliot" created="Sat, 24 Jul 2010 01:22:53 +0000"  >&lt;p&gt;you should try 2.0 &lt;/p&gt;</comment>
                    </comments>
                    <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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhd0v:</customfieldvalue>

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