<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:59:22 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-42034] Remove numStr from BSONObjBuilder</title>
                <link>https://jira.mongodb.org/browse/SERVER-42034</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description></description>
                <environment></environment>
        <key id="831038">SERVER-42034</key>
            <summary>Remove numStr from BSONObjBuilder</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="billy.donahue@mongodb.com">Billy Donahue</assignee>
                                    <reporter username="adam.martin@mongodb.com">ADAM Martin</reporter>
                        <labels>
                    </labels>
                <created>Mon, 1 Jul 2019 23:28:16 +0000</created>
                <updated>Sun, 29 Oct 2023 22:19:22 +0000</updated>
                            <resolved>Mon, 29 Jul 2019 15:37:38 +0000</resolved>
                                                    <fixVersion>4.3.1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="2347985" author="xgen-internal-githook" created="Mon, 29 Jul 2019 14:59:13 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-42034&quot; title=&quot;Remove numStr from BSONObjBuilder&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-42034&quot;&gt;&lt;del&gt;SERVER-42034&lt;/del&gt;&lt;/a&gt; Optimize ItoA&lt;/p&gt;

&lt;p&gt;    (~13% faster, remove the 1kLoC static table)&lt;br/&gt;
    Reverts commit 7c9edfd4b931f3d3208142b411010b6b4afee21e.&lt;br/&gt;
    Python-generate table-emitting macro (compiler workaround).&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/dae371c478e1a828ac911096d85f94be8e936ef9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/dae371c478e1a828ac911096d85f94be8e936ef9&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2337758" author="xgen-internal-githook" created="Mon, 22 Jul 2019 22:04:02 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ian Boros&apos;, &apos;username&apos;: &apos;puppyofkosh&apos;, &apos;email&apos;: &apos;puppyofkosh@gmail.com&apos;}
&lt;p&gt;Message: Revert &quot;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-42034&quot; title=&quot;Remove numStr from BSONObjBuilder&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-42034&quot;&gt;&lt;del&gt;SERVER-42034&lt;/del&gt;&lt;/a&gt; Optimize ItoA (~13% faster, remove the 1kLoC static table)&quot;&lt;/p&gt;

&lt;p&gt;This reverts commit be18bd1133d6f8118ebb79a2251c4a49b1c84ec1.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/7c9edfd4b931f3d3208142b411010b6b4afee21e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/7c9edfd4b931f3d3208142b411010b6b4afee21e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2337659" author="xgen-internal-githook" created="Mon, 22 Jul 2019 21:17:55 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-42034&quot; title=&quot;Remove numStr from BSONObjBuilder&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-42034&quot;&gt;&lt;del&gt;SERVER-42034&lt;/del&gt;&lt;/a&gt; Optimize ItoA (~13% faster, remove the 1kLoC static table)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/be18bd1133d6f8118ebb79a2251c4a49b1c84ec1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/be18bd1133d6f8118ebb79a2251c4a49b1c84ec1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2317630" author="xgen-internal-githook" created="Tue, 9 Jul 2019 18:32:25 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-42034&quot; title=&quot;Remove numStr from BSONObjBuilder&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-42034&quot;&gt;&lt;del&gt;SERVER-42034&lt;/del&gt;&lt;/a&gt; remove BSONObjBuilder::numStr&lt;/p&gt;

&lt;p&gt;   Callers are better with either DecimalCounter or std::to_string.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/f2bb23436a46afacfc8e3dc65fda743fafe6b2c3&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/f2bb23436a46afacfc8e3dc65fda743fafe6b2c3&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2311862" author="billy.donahue" created="Wed, 3 Jul 2019 22:07:56 +0000"  >&lt;p&gt;I LGTMed the CR to implement this change because I see several stylistic, performance, and even correctness reasons to get rid of these static strings. I doubt they were providing a realistic performance benefit, but that&apos;s not the most important thing.&lt;/p&gt;

&lt;p&gt;The most pressing issue to me is the undefined init-time behavior of the numStr() function, relying on assumptions about the C++ implementation that don&apos;t hold up to close scrutiny. Specifically, the early read of numStrsReady in BSONObjBuilder::numStr() is undefined behavior invoked on purpose in an effort to protect us from other undefined behavior. The comment above numStrsReady&apos;s definition is untrue. Reading it early will yield undefined behavior, not a false value.&lt;/p&gt;

&lt;p&gt;Would an implementation be allowed to &quot;prove&quot; to itself that numStrsReady is always true, and just static-initialize it as an optimization? As a template, all of std::basic_string is visible to the compiler, so I think it&apos;s possible that numStrsReady offers no protection at all from early accesses to the numStrs array, and it&apos;s just a waste of CPU time to look at it. But it&apos;s a non-const static duration bool that&apos;s initialized to true, but it isn&apos;t guaranteed to remain true, so numStr() would still have to waste time looking at it.&lt;/p&gt;

&lt;p&gt;Even if this static-init optimization isn&apos;t happening, we would still have a race. The initialization of the numStrs array is not ordered wrt potentially early callers of the inline function BSONObjBuilder::numStr(). We are not guaranteed any order at all between definitions in different translation units and we are not guaranteed by C++ that pre-main() is single-threaded. BSONObjBuilder::numStr can be invoked by a static initializer anywhere. It is even allowed to run concurrently with the initialization of numStrsReady or numStrs, and there&apos;s no synchronization provided by the numStr function, so it could be read while being updated.&lt;/p&gt;

&lt;p&gt;There are other fixes available for these problems, but I think the simplest is to just remove the static strings altogether.&lt;br/&gt;
 It&apos;s not okay to leave the UB and init races in the code, however, so I disagree with the proposal to close this one.&lt;/p&gt;

&lt;p&gt;Performance-wise, I think the 0-99 numStrs table will make short arrays quicker to write, but long arrays slower to write. But the benefits for short arrays would be swamped by the other processing that happens while preparing the enclosing object. That is, I think we&apos;d be optimizing a drop in the bucket for short arrays. But for long arrays, we&apos;re making the whole bucket slower.&lt;/p&gt;


&lt;p&gt;We should just rip BSONObjBuilder::numStr out. The uses internal to BSONObjBuilder are better served by DecimalCounter.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://docs.google.com/spreadsheets/d/1eOsD8EPCmVTLLfl3_HRG1yYrw2I79oJiDJRb_BdCyks/edit?usp=sharing&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.google.com/spreadsheets/d/1eOsD8EPCmVTLLfl3_HRG1yYrw2I79oJiDJRb_BdCyks/edit?usp=sharing&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;The 20 or so uses outside BSONObjBuilder have nothing to do with BSONObj. They usually are incrementing a field name and should use DecimalCounter as well.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="2309915" author="acm" created="Tue, 2 Jul 2019 17:23:16 +0000"  >&lt;p&gt;I don&apos;t think we should do it. I suggest we close this ticket.&lt;/p&gt;</comment>
                            <comment id="2309904" author="milkie" created="Tue, 2 Jul 2019 17:17:48 +0000"  >&lt;p&gt;What is the reasoning behind doing this work now &amp;#8211; what is blocked behind it?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10020">
                    <name>Gantt Dependency</name>
                                                                <inwardlinks description="has to be done after">
                                        <issuelink>
            <issuekey id="824806">SERVER-41989</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.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>Tue, 2 Jul 2019 17:17:48 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 28 weeks, 2 days 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_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>
                            4 years, 28 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>adam.martin@mongodb.com</customfieldvalue>
            <customfieldvalue>andrew.morrow@mongodb.com</customfieldvalue>
            <customfieldvalue>billy.donahue@mongodb.com</customfieldvalue>
            <customfieldvalue>milkie@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hv9z0v:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hv5mnj:</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="3033">Dev Tools 2019-07-15</customfieldvalue>
    <customfieldvalue id="3111">Dev Tools 2019-07-29</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|hv9la7:</customfieldvalue>

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