Subject: [Boost-bugs] [Boost C++ Libraries] #9662: High CPU usage for steady_clock waitable timer on Windows (integer overflow problem)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-12 06:52:35
#9662: High CPU usage for steady_clock waitable timer on Windows (integer overflow
problem)
-------------------------------------------------+-------------------------
Reporter: wyatt@⦠| Owner:
Type: Bugs | chris_kohlhoff
Milestone: To Be Determined | Status: new
Version: Boost 1.55.0 | Component: asio
Keywords: asio, SetWaitableTimer, | Severity: Problem
basic_waitable_timer, steady_clock |
-------------------------------------------------+-------------------------
Hey Guys & Girls,
I've tracked down a bug in your waitable timer implementation on Windows.
Specifically the update_timeout() function in
"boost/asio/detail/impl/win_iocp_io_service.ipp". More specifically the
SetWaitableTimer() call in that function for certain "timeout_usec"
values.
Specifically, for certain large "wait values" the current implementation
thrashes the CPU using up nearly all the CPU time on a "core" of the
processor. Obviously that's not ideal.
I haven't tracked down the exact place where things go wrong, nor have I
written a patch. If I get some free time in a month or 2 I might do it if
no one else wants to pick it up.
Here's how you can reproduce it. (If you want I can put together a full
example for you)
{{{
typedef boost::asio::basic_waitable_timer<boost::chrono::steady_clock>
monotonic_timer;
monotonic_timer buggy_timer_(io_service_);
buggy_timer_.expires_from_now(boost::chrono::seconds(86400));
buggy_timer_.async_wait(boost::bind(&server::callback_function, this,
boost::asio::placeholders::error));
io_service_.run()
}}}
The problem lies with this:
{{{
boost::chrono::seconds(86400)
}}}
If you use a value half as large (43200 seconds) then the program uses
normal CPU levels (i.e. around 0% CPU). Obviously we've got an integer
overflow problem and faulty logic. As I said, I believe it's in the
update_timeout() function in
"boost/asio/detail/impl/win_iocp_io_service.ipp"
If you need more information just ask and I'll be glad to provide it.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9662> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC