<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:58:31 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-2986] Improve performance of the legacy JSON parse by not calling containsField(&quot;$...&quot;) for arrays</title>
                <link>https://jira.mongodb.org/browse/JAVA-2986</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Profiling our use case showed a lot of time being spent with callstacks as per the below - throwing exceptions in parsing JSON.&lt;/p&gt;

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

&lt;p&gt;What seems to be happening is we have a JSONCallback which we call arrayDone on.&#160; That&apos;s not implemented by JSONCallback, but by BasicBSONCallback implements arrayDone() by calling objectDone().&#160; There&apos;s some attempt to skip the bulk of JSONCallback.objectDone if the last object was an array with the _lastArray member of JSONCallback, but that&apos;s flawed - if you have an array of objects, you&apos;ll get callbacks:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;arrayStart (sets _lastArray = true)&lt;/li&gt;
	&lt;li&gt;objectStart (sets _lastArray = false)&lt;/li&gt;
	&lt;li&gt;objectDone&lt;/li&gt;
	&lt;li&gt;arrayDone -&amp;gt; objectDone (_lastArray is false)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Rather than this messing about with _lastArray, surely implementing arrayDone() as super.arrayDone (so that BasicBSONCallback can maintain its stack state) would be simpler and more correct - and avoid the below problem?&lt;/p&gt;

&lt;p&gt;Currently, when parsing an array of objects, we execute all of JSONCallback.objectDone for the array, calling containsField(&quot;$...&quot;) for each of the supported Extended JSON attributes.&#160; The implementation of BasicBSONList is to attempt to parse its argument as an Integer, which throws an exception.&#160; This is problematic, as creating exceptions is expensive (as it happens, this was 200 stack frames down, so each exception&apos;s fillInStackTrace as its created is quite expensive...)&lt;/p&gt;

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

&lt;p&gt;(An alternative fix is to make BasicBSONList.containsField check the first character - if it&apos;s not in the range 0..9, then just return false - bypassing the exception codepath for this common case)&lt;/p&gt;

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

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Throwable.fillInStackTrace(Native Method)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Throwable.fillInStackTrace(Throwable.java:783)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; - locked &amp;lt;0x000000073da6fd40&amp;gt; (a java.lang.NumberFormatException)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Throwable.&amp;lt;init&amp;gt;(Throwable.java:265)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Exception.&amp;lt;init&amp;gt;(Exception.java:54)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.RuntimeException.&amp;lt;init&amp;gt;(RuntimeException.java:62)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.IllegalArgumentException.&amp;lt;init&amp;gt;(IllegalArgumentException.java:52)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.NumberFormatException.&amp;lt;init&amp;gt;(NumberFormatException.java:55)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Integer.parseInt(Integer.java:569)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Integer.parseInt(Integer.java:615)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:165)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.bson.types.BasicBSONList.containsField(BasicBSONList.java:135)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSONCallback.objectDone(JSONCallback.java:130)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.bson.BasicBSONCallback.arrayDone(BasicBSONCallback.java:139)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSONParser.parseArray(JSON.java:628)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSONParser.parse(JSON.java:224)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSONParser.parseObject(JSON.java:264)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSONParser.parse(JSON.java:228)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSONParser.parse(JSON.java:156)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSON.parse(JSON.java:98)&lt;/p&gt;

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.mongodb.util.JSON.parse(JSON.java:79)&lt;/p&gt;</description>
                <environment></environment>
        <key id="607446">JAVA-2986</key>
            <summary>Improve performance of the legacy JSON parse by not calling containsField(&quot;$...&quot;) for arrays</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="cree">Chris Reed</reporter>
                        <labels>
                    </labels>
                <created>Thu, 20 Sep 2018 08:58:08 +0000</created>
                <updated>Thu, 11 Oct 2018 15:40:12 +0000</updated>
                            <resolved>Thu, 11 Oct 2018 15:40:12 +0000</resolved>
                                    <version>3.6.4</version>
                                                    <component>JSON</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="2030200" author="jeff.yemin" created="Thu, 11 Oct 2018 15:40:12 +0000"  >&lt;p&gt;The &lt;tt&gt;JSON&lt;/tt&gt; class is deprecated and will be removed in the next major release, so we&apos;re not going to invest time in its improvement.&lt;/p&gt;

&lt;p&gt;Users of the &lt;tt&gt;JSON&lt;/tt&gt; class should migrate to &lt;tt&gt;JsonReader&lt;/tt&gt; at their earliest convenience.&lt;/p&gt;</comment>
                    </comments>
                    <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|htyw67:</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>