Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-14 Thread Mike Crowe via Gcc-patches
On Saturday 14 November 2020 at 00:17:22 +, Jonathan Wakely wrote: > On 13/11/20 22:45 +, Jonathan Wakely wrote: > > On 13/11/20 21:12 +, Jonathan Wakely wrote: > > > On 13/11/20 20:29 +, Mike Crowe via Libstdc++ wrote: > > > > On Friday 13 November 2020 at 17:25:22 +, Jonathan

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
On 13/11/20 22:45 +, Jonathan Wakely wrote: On 13/11/20 21:12 +, Jonathan Wakely wrote: On 13/11/20 20:29 +, Mike Crowe via Libstdc++ wrote: On Friday 13 November 2020 at 17:25:22 +, Jonathan Wakely wrote: + // Return the relative duration from (now_s + now_ns) to (abs_s + abs

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
On 13/11/20 21:12 +, Jonathan Wakely wrote: On 13/11/20 20:29 +, Mike Crowe via Libstdc++ wrote: On Friday 13 November 2020 at 17:25:22 +, Jonathan Wakely wrote: + // Return the relative duration from (now_s + now_ns) to (abs_s + abs_ns) + // as a timespec. + struct timespec + r

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
On 13/11/20 21:12 +, Jonathan Wakely wrote: On 13/11/20 20:29 +, Mike Crowe via Libstdc++ wrote: On Friday 13 November 2020 at 17:25:22 +, Jonathan Wakely wrote: + // Return the relative duration from (now_s + now_ns) to (abs_s + abs_ns) + // as a timespec. + struct timespec + r

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
On 13/11/20 20:29 +, Mike Crowe via Libstdc++ wrote: On Friday 13 November 2020 at 17:25:22 +, Jonathan Wakely wrote: + // Return the relative duration from (now_s + now_ns) to (abs_s + abs_ns) + // as a timespec. + struct timespec + relative_timespec(chrono::seconds abs_s, chrono::n

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Mike Crowe via Gcc-patches
On Friday 13 November 2020 at 17:25:22 +, Jonathan Wakely wrote: > On 13/11/20 11:02 +, Jonathan Wakely wrote: > > On 12/11/20 23:49 +, Jonathan Wakely wrote: > > > To poll a std::future to see if it's ready you have to call one of the > > > timed waiting functions. The most obvious way

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
>Backporting the change to gcc-10 revealed an overflow bug in the >existing code, resulting in blocking for years when given an absolute >timeout in the distant past. There's still a similar bug in the new >code (using futexes with absolute timeouts against clocks) where a >large chrono::seconds va

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
On 13/11/20 11:02 +, Jonathan Wakely wrote: On 12/11/20 23:49 +, Jonathan Wakely wrote: To poll a std::future to see if it's ready you have to call one of the timed waiting functions. The most obvious way is wait_for(0s) but this was previously very inefficient because it would turn the

Re: [committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-13 Thread Jonathan Wakely via Gcc-patches
On 12/11/20 23:49 +, Jonathan Wakely wrote: To poll a std::future to see if it's ready you have to call one of the timed waiting functions. The most obvious way is wait_for(0s) but this was previously very inefficient because it would turn the relative timeout to an absolute one by calling sy

[committed] libstdc++: Optimise std::future::wait_for and fix futex polling

2020-11-12 Thread Jonathan Wakely via Gcc-patches
To poll a std::future to see if it's ready you have to call one of the timed waiting functions. The most obvious way is wait_for(0s) but this was previously very inefficient because it would turn the relative timeout to an absolute one by calling system_clock::now(). When the relative timeout is ze