Subject: [Boost-bugs] [Boost C++ Libraries] #4780: Many deadline_timer objects triggers worst-case vector reallocation in timer_queue
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-24 01:56:07
#4780: Many deadline_timer objects triggers worst-case vector reallocation in
timer_queue
------------------------------+---------------------------------------------
Reporter: chris_kohlhoff | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.44.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
Using the g++ 4.4.5 on linux x86_64, the following program:
{{{
#include <boost/asio/deadline_timer.hpp>
boost::asio::io_service io_service;
struct timer
{
boost::asio::deadline_timer t;
timer() : t(io_service) {}
} timers[100000];
void handler(boost::system::error_code) {}
int main()
{
for (std::size_t i = 0; i < 100000; ++i)
{
timers[i].t.expires_from_now(boost::posix_time::seconds(1000));
timers[i].t.async_wait(handler);
}
}
}}}
takes a very long time to run:
{{{
$ time ./a.out
real 0m48.504s
user 0m21.469s
sys 0m27.038s
}}}
This is due to the vector<>-based heap in asio::detail::timer_queue
reserve()-ing one element at a time.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4780> 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:04 UTC