Improve windows timer precision when dealing with duration < 1ms with a CPU trade-off#24
Conversation
… a CPU trade-off add macro definition BOOST_ASIO_ENABLE_CPU_TIMER_TRADE_OFF to enable it
|
I did test you sample program on my machine and did not get anywhere as close results as you have. Did you change something in windows to get more accurate timers? My system is Windows 8.1 (x64). I compiled your test-program with Visual Studio 2013 for x64. I did not patch boost::asio. My results look more like this: In my experience you can't rely that the timer is more accurate than 15ms. |
|
We did not change anything in Windows settings. Anyway, it would be great to have a way to improve asio timer resolution when deadling with short wait duration. |
|
Because of the said limitation I would vote against the your change in boost::asio. For your problem (10-15Mbit/s vs 300Mbit/s) I would suggest you do your timer like now and check after you got called how much time really passed and "repair" the number of packets you wanted to send. This is not optimal, but will work "okay" on all timer resolutions. You can profit from good timers (like 1ms) and also work "okay" on bad timers (like 15ms). |
|
Well, we understand your point. For testing purpose, we will implement a new timer service based on busy loop and see if it is conclusive. |
|
Looking for another solution (#25) |
Hi Chris,
While developing our boost.asio stream socket based on UDT protocol, we encountered performance issues using asio timers on Windows.
UDT protocol adjusts numerous critical variables for its internal dataflow and bandwidth management using micro timing events.
The proposed patch improves asio timer precision when dealing with short wait duration (< 1 ms) with a CPU trade-off, activable using macro definition "BOOST_ASIO_ENABLE_CPU_TIMER_TRADE_OFF".
On UDT implementation, this patch leads to a dramatically increased bandwidth (from 10-15Mbit/s up to 300Mbit/s approx).
Without it, boost asio's timer could not be used when "high" precision is required.
What do you think about it ?
Please, find enclosed a test program that can be used to get an idea of patch's impact on sub-millisecond timers.
Here are some results we get :
Without patch :
With patch :