<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:47:27 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-81797] Make our own portable implementation of atomic notify() and wait() with timeout support</title>
                <link>https://jira.mongodb.org/browse/SERVER-81797</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;In a few places we&apos;ve either wanted to use C++20&apos;s &lt;tt&gt;std::atomic::wait()&lt;/tt&gt; and &lt;tt&gt;notify&lt;/tt&gt; apis, or have code currently using a mutex+condvar+enum/bool that could be using that instead. Unfortunately, the sandardized APIs don&apos;t support timeouts or deadlines (due to issues around freestanding support) while effectively all of our usages need them. Luckily, all of the OSes we support provide APIs that do take timeouts or deadlines, so we should just build our own wait/notify abstraction on top of them. We can use the &lt;tt&gt;try_wait_for&lt;/tt&gt; and &lt;tt&gt;try_wait_until&lt;/tt&gt; APIs proposed &lt;a href=&quot;https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2643r1.html#Fallible-and-timed-versions-of-wait-APIs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;. We can base it on the implementation in &lt;a href=&quot;https://github.com/llvm/llvm-project/blob/1482106c9960300e729b1a58e5e25b6ac1c150ba/libcxx/src/atomic.cpp#L45-L118&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;libc++&lt;/a&gt; (covering linux, apple/darwin, and freebsd) and use &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;WaitOnAddress&lt;/a&gt; / &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-wakebyaddresssingle&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;WakeByAddressSingle&lt;/a&gt; /  &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-wakebyaddressall&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;WakeByAddressAll&lt;/a&gt; on windows (the MSSTL &lt;a href=&quot;https://github.com/microsoft/STL/blob/main/stl/src/atomic_wait.cpp&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;implementation&lt;/a&gt; is convoluted to support old windows versions without those APIs, but we dont need to support them).&lt;/p&gt;

&lt;p&gt;I think it would be best to add a new &lt;tt&gt;AtomicWaitable&amp;lt;T&amp;gt;&lt;/tt&gt; type that publicly derives from &lt;tt&gt;AtomicWord&amp;lt;T&amp;gt;&lt;/tt&gt; but ensures that `T` is a size that is supported natively by the current platform (all platforms seem to support 32bit words, so we could just require that everywhere). We could also consider adding a fallback implementation that adds a mutex+condvar to the subclass and uses them for notifications. If &lt;tt&gt;sizeof(T)&lt;/tt&gt; is smaller than the platform natively supports (eg &lt;tt&gt;bool&lt;/tt&gt; on linux) we could consider padding it out and using an underlying &lt;tt&gt;AtomicWaitable&amp;lt;uint32_t&amp;gt;&lt;/tt&gt; rather than failing to compile and requiring the caller to do their own padding.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2457264">SERVER-81797</key>
            <summary>Make our own portable implementation of atomic notify() and wait() with timeout support</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="10018" iconUrl="https://jira.mongodb.org/images/icons/statuses/visible.png" description="">In Code Review</status>
                    <statusCategory id="4" key="indeterminate" colorName="inprogress"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="vinod.kumar@mongodb.com">Vinod Kumar</assignee>
                                    <reporter username="mathias@mongodb.com">Mathias Stearn</reporter>
                        <labels>
                            <label>perf-8.0</label>
                            <label>perf-tiger</label>
                            <label>perf-tiger-handoff</label>
                            <label>perf-tiger-q4</label>
                            <label>perf-tiger-triaged</label>
                            <label>risk</label>
                    </labels>
                <created>Tue, 3 Oct 2023 13:51:58 +0000</created>
                <updated>Wed, 7 Feb 2024 18:09:21 +0000</updated>
                                                                                                <votes>0</votes>
                                    <watches>17</watches>
                                                                                                                <comments>
                            <comment id="5751325" author="redbeard0531" created="Wed, 4 Oct 2023 09:47:32 +0000"  >&lt;p&gt;To add some background, I confirmed with the original proposer of the atomic wait/notify APIs for c&amp;#43;&amp;#43;20 that they were omitted at the time to avoid issues with freestanding (ie C&amp;#43;&amp;#43; implementations without an OS). &lt;tt&gt;&amp;lt;atomic&amp;gt;&lt;/tt&gt; has always been part of freestanding but &lt;tt&gt;&amp;lt;chrono&amp;gt;&lt;/tt&gt; isn&apos;t, so it &lt;del&gt;isn&apos;t&lt;/del&gt; wasn&apos;t possible to use the time types from &lt;tt&gt;std::atomic&lt;/tt&gt;. Since then, there has been a relaxation of freestanding to allow fine grained selection of what is and is not required to be available in a freestanding implementation, so it is now possible to add those methods and have just them be optional on freestanding implementations without affecting the rest of the &lt;tt&gt;std::atomic&lt;/tt&gt; API. That is what the &lt;tt&gt;try_wait*&lt;/tt&gt; APIs in &lt;a href=&quot;https://wg21.link/P2643&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;P2643&lt;/a&gt; are doing. That proposal is currently working its way through the committee and it seems on track for C++26. So we should probably mirror those APIs if we want to have the option to cut over to the standard APIs later. Plus, if we run into issues with them, we can provide feedback and hopefully get them addressed prior to standardization.&lt;/p&gt;

&lt;p&gt;That said, I still think it is worth adding a separate type for notifiable atomics so that we can use a different representation with extra inline data for types that the platform doesn&apos;t natively support waiting on. That isn&apos;t an option in the standard because &lt;tt&gt;std::atomic&lt;/tt&gt; has a fixed ABI in practice, but we are not bound by that restriction in our code.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="2227652">SERVER-72616</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2495410">SERVER-83053</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2457209">SERVER-81793</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2570122">SERVER-86362</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2209237">SERVER-72064</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2476456">WT-11836</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>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25132"><![CDATA[Service Arch]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 8 Nov 2023 18:59:12 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        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_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>vinod.kumar@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            18 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>vinod.kumar@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i2t4gf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i2b1n8:</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="7936">Service Arch 2023-12-11</customfieldvalue>
    <customfieldvalue id="7937">Service Arch 2023-12-25</customfieldvalue>
    <customfieldvalue id="8038">Service Arch 2024-01-08</customfieldvalue>
    <customfieldvalue id="8039">Service Arch 2024-01-22</customfieldvalue>
    <customfieldvalue id="8040">Service Arch 2024-02-05</customfieldvalue>
    <customfieldvalue id="8041">Service Arch 2024-02-19</customfieldvalue>

                        </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|i2sqlr:</customfieldvalue>

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