<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:35:20 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>[SERVER-55057] Improvements to ComparisonMatchExpressions</title>
                <link>https://jira.mongodb.org/browse/SERVER-55057</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There are some low-hanging-fruit optimizations available to &lt;tt&gt;ComparisonMatchExpression&lt;/tt&gt;:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Call &lt;tt&gt;canonicalType()&lt;/tt&gt; less
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-55043&quot; title=&quot;canonicalizeBSONType() should be implemented as a lookup table&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-55043&quot;&gt;&lt;del&gt;SERVER-55043&lt;/del&gt;&lt;/a&gt; will help a lot, but testing shows it is still faster to avoid canonicalizing where possible.&lt;/li&gt;
		&lt;li&gt;You only need to enter the first block if the &lt;tt&gt;type()&lt;/tt&gt; doesn&apos;t match since same type implies same canonical type. This optimization is already done in &lt;a href=&quot;https://github.com/mongodb/mongo/blob/23cbaca35ac3e44cb0e85b0da24e5dac646033db/src/mongo/bson/bsonelement.cpp#L472-L477&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;woCompare&lt;/tt&gt;&lt;/a&gt;, so this is about doing the same thing in &lt;tt&gt;CME&lt;/tt&gt;.&lt;/li&gt;
		&lt;li&gt;Inside the &lt;tt&gt;if&lt;/tt&gt; block it immediately canonicalizes again.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Optimize NaN checks
	&lt;ul&gt;
		&lt;li&gt;The special NaN logic isn&apos;t needed for &lt;tt&gt;EQ&lt;/tt&gt; because it is already done correctly and efficiently in that case by &lt;tt&gt;BSONElement::compareElements&lt;/tt&gt;.&lt;/li&gt;
		&lt;li&gt;It will do the NaN checks even for non-numeric types, such as strings. The logic ends up being correct, but it is wasteful.&lt;/li&gt;
		&lt;li&gt;It recomputes whether &lt;tt&gt;_rhs&lt;/tt&gt; is NaN every time even though _rhs doesn&apos;t change.&lt;/li&gt;
		&lt;li&gt;It checks whether Int and Long are NaN, even though they don&apos;t have a NaN representation&lt;/li&gt;
		&lt;li&gt;It does an expensive Decimal -&amp;gt; double conversion just to check for nan, rather than checking for NaN while still a Decimal.&lt;/li&gt;
		&lt;li&gt;It then repeats the NaN check for both &lt;tt&gt;_rhs&lt;/tt&gt; and &lt;tt&gt;e&lt;/tt&gt; if either is NaN to check if both are NaN.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Do an early-out check when doing &lt;tt&gt;EQ&lt;/tt&gt; comparisons with &lt;tt&gt;String&lt;/tt&gt; to see if the lengths don&apos;t match before comparing contents.
	&lt;ul&gt;
		&lt;li&gt;&lt;tt&gt;woCompare&lt;/tt&gt;/&lt;tt&gt;compareElements&lt;/tt&gt; can&apos;t do that because it doesn&apos;t know if the caller is interested in just equality or relative order, but we know that here.&lt;/li&gt;
		&lt;li&gt;We can only do that with the simple collator, but that seems like a case worth optimizing for.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I&apos;m attaching a patch which addresses all of these. I saw a huge improvement in perf with this patch vs without.&lt;/p&gt;

&lt;p&gt;I also tried templating &lt;tt&gt;ComparisonMatchExpression::matchesSingleElement&lt;/tt&gt; as &lt;tt&gt;matchesSingleElementImpl&amp;lt;MatchType&amp;gt;&lt;/tt&gt; and calling it from each of the subclasses&apos; &lt;tt&gt;matchesSingleElement()&lt;/tt&gt; so that all of the branching on &lt;tt&gt;matchType()&lt;/tt&gt; would compile away, but I didn&apos;t see any improvement in my workload, so I didn&apos;t include it in this patch. It is possible that workloads involving more than one &lt;tt&gt;MatchType&lt;/tt&gt; would see some benefit, so it may be worth exploring in the future.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1644340">SERVER-55057</key>
            <summary>Improvements to ComparisonMatchExpressions</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="13201">Fixed</resolution>
                                        <assignee username="bikash.chandra@mongodb.com">Bikash Chandra</assignee>
                                    <reporter username="mathias@mongodb.com">Mathias Stearn</reporter>
                        <labels>
                            <label>neweng</label>
                    </labels>
                <created>Tue, 9 Mar 2021 10:58:49 +0000</created>
                <updated>Sun, 29 Oct 2023 21:56:32 +0000</updated>
                            <resolved>Mon, 23 Aug 2021 14:27:03 +0000</resolved>
                                                    <fixVersion>5.1.0-rc0</fixVersion>
                                    <component>Performance</component>
                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="4108111" author="JIRAUSER1259052" created="Wed, 6 Oct 2021 18:57:22 +0000"  >&lt;p&gt;Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it&#8217;s been triggered. For more active release information, please keep an eye on #server-release. Thank you!&lt;/p&gt;</comment>
                            <comment id="4016812" author="xgen-internal-githook" created="Mon, 23 Aug 2021 14:23:25 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Bikash Chandra&apos;, &apos;email&apos;: &apos;bikash.chandra@Bikashs-MacBook-Pro.local&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-55057&quot; title=&quot;Improvements to ComparisonMatchExpressions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-55057&quot;&gt;&lt;del&gt;SERVER-55057&lt;/del&gt;&lt;/a&gt; Improvements to ComparisonMatchExpressions&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/1c458cebc23d20bf259d3774498b5080b7565ca1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/1c458cebc23d20bf259d3774498b5080b7565ca1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3956885" author="JIRAUSER1259232" created="Thu, 22 Jul 2021 08:11:21 +0000"  >&lt;p&gt;For Bikash.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="303944" name="matcher.patch" size="7484" author="mathias@mongodb.com" created="Tue, 9 Mar 2021 10:49:12 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 22 Jul 2021 08:11:21 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 18 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-2155</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 18 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>bikash.chandra@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>rushan.chen@mongodb.com</customfieldvalue>
            <customfieldvalue>vivian.ge@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hyyp13:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2z1r:</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_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="4715">QE 2021-08-23</customfieldvalue>
    <customfieldvalue id="4717">QE 2021-09-06</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hyyba7:</customfieldvalue>

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