<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:38:24 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>[GODRIVER-2361] Investigate using &quot;x/exp/rand&quot; or &quot;google/uuid&quot; packages to improve UUID generation</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2361</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;While investigating &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2349&quot; title=&quot;Prevent session ID reuse due to lower-than-expected system clock resolution&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2349&quot;&gt;&lt;del&gt;GODRIVER-2349&lt;/del&gt;&lt;/a&gt;, we discovered that the Go &quot;math/rand&quot; package &lt;tt&gt;Seed&lt;/tt&gt; functions drop half of the 64 bits of entropy provided (see code &lt;a href=&quot;https://cs.opensource.google/go/go/+/refs/tags/go1.18:src/math/rand/rng.go;l=204&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;). There is also an open &lt;a href=&quot;https://github.com/golang/go/issues/36133&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Go issue&lt;/a&gt; requesting more documentation on the behaviors and algorithms in the &quot;math/rand&quot; package (see &lt;a href=&quot;https://github.com/golang/go/issues/36133#issuecomment-738964377&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this comment&lt;/a&gt; specifically asking about truncating the seed value). There is an open &lt;a href=&quot;https://github.com/golang/go/issues/21835&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Go proposal&lt;/a&gt; to replace the pseudo-random number algorithms used in the &quot;math/rand&quot; package, either in a Go 1.x release or in Go 2.0. In both places, Rob Pike suggests using the &lt;a href=&quot;https://pkg.go.dev/golang.org/x/exp/rand&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;golang.org/x/exp/rand&lt;/a&gt; package to replace &quot;math/rand&quot;, with the caveat that there may be performance regression until the compiler supports using per-platform 64-bit multiply and add instructions, which it &lt;a href=&quot;https://github.com/golang/go/issues/24813&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;now does&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Additionally, the &lt;a href=&quot;https://github.com/google/uuid&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;google/uuid&lt;/a&gt; package supports pooling random values for generating random UUIDv4 values, which may mitigate the performance impact of using &quot;crypto/rand&quot;. We should consider using that dependency to replace the &quot;uuid&quot; package.&lt;/p&gt;

&lt;p&gt;tldr; We should investigate if using the &lt;a href=&quot;https://pkg.go.dev/golang.org/x/exp/rand&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;golang.org/x/exp/rand&lt;/a&gt; or &lt;a href=&quot;https://github.com/google/uuid&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;github.com/google/uuid&lt;/a&gt; packages would make a meaningful improvement, either in simplicity of code or performance. If so, we should update the session ID UUID generator to use the best package.&lt;/p&gt;

&lt;p&gt;Definition of done:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Prototype using &quot;x/exp/rand&quot; and &quot;google/uuid&quot; packages to see if they simplify the pseudo-random number generator use cases in the driver.&lt;/li&gt;
	&lt;li&gt;Benchmark UUID generation with &quot;crypto/rand&quot;, &quot;math/rand&quot;, &quot;x/exp/rand&quot;, and using &quot;google/uuid&quot; (on macOS and on Linux) to see if there is a meaningful improvement in any case.&lt;/li&gt;
	&lt;li&gt;If there is a better approach, update the Go driver UUID generator to use &quot;x/exp/rand&quot;, &quot;google/uuid&quot;, or revert to using &quot;crypto/rand&quot;.&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="2011863">GODRIVER-2361</key>
            <summary>Investigate using &quot;x/exp/rand&quot; or &quot;google/uuid&quot; packages to improve UUID generation</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</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="qingyang.hu@mongodb.com">Qingyang Hu</assignee>
                                    <reporter username="matt.dale@mongodb.com">Matt Dale</reporter>
                        <labels>
                            <label>neweng</label>
                            <label>techdebt</label>
                    </labels>
                <created>Wed, 30 Mar 2022 03:40:43 +0000</created>
                <updated>Sat, 28 Oct 2023 11:37:37 +0000</updated>
                            <resolved>Mon, 23 May 2022 13:18:54 +0000</resolved>
                                                    <fixVersion>1.10.0</fixVersion>
                    <fixVersion>1.10.0-beta1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="4565943" author="xgen-internal-githook" created="Mon, 23 May 2022 13:17:52 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Qingyang Hu&apos;, &apos;email&apos;: &apos;103950869+qingyang-hu@users.noreply.github.com&apos;, &apos;username&apos;: &apos;qingyang-hu&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2361&quot; title=&quot;Investigate using &amp;quot;x/exp/rand&amp;quot; or &amp;quot;google/uuid&amp;quot; packages to improve UUID generation&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2361&quot;&gt;&lt;del&gt;GODRIVER-2361&lt;/del&gt;&lt;/a&gt; Refactor pseudo-random number and UUID generation with &quot;golang.org/x/exp/rand&quot; (#945)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/ef8ad53b17d04227ae5c835b1bab1cfbac818363&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/ef8ad53b17d04227ae5c835b1bab1cfbac818363&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4536177" author="david.golden" created="Mon, 9 May 2022 18:27:18 +0000"  >&lt;p&gt;I see that mt19937 is unfortunately GPL3, but perhaps there are other MT libraries with more permissive licenses.&#160; E.g. here&apos;s one: &lt;a href=&quot;https://github.com/goark/mt&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/goark/mt&lt;/a&gt; with an MIT license.&lt;/p&gt;

&lt;p&gt;As I suggested earlier, I think a mix of a static, per-process crypto portion plus per-UUID random bits from a (crypto-seeded) MT PRNG for the remaining bits is going to give the best safety/performance tradeoff.&lt;/p&gt;</comment>
                            <comment id="4448508" author="david.golden" created="Thu, 31 Mar 2022 18:45:28 +0000"  >&lt;p&gt;For non-crypto PRNG, I suggest also benchmarking a Mersenne Twister PRNG like &lt;a href=&quot;https://pkg.go.dev/github.com/seehuhn/mt19937&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://pkg.go.dev/github.com/seehuhn/mt19937&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&apos;d also add that I&apos;d strongly prefer strong uniqueness over performance unless there is some compelling reason why UUID generation is a hotspot in the code.  In that regard, I&apos;d look to develop a real-world benchmark that exercises UUID generation (inserting into lots of explicit sessions?) and see how much difference the UUID generator makes in that context.&lt;/p&gt;

&lt;p&gt;As one final thought, you could consider applying the UUID RFC recommendation in &lt;a href=&quot;https://datatracker.ietf.org/doc/html/rfc4122#section-4.5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;section 4.5&lt;/a&gt; and generate 47-bits from a CSPRNG once per process and use it for all UUIDs (with the rest of the bits filled in with a PRNG as you do today).  This might balance uniqueness with generation speed.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2004618">GODRIVER-2349</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1921732">GODRIVER-2223</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|hz94it:</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>