fix excessive CPU consumption of timer_server
fix excessive CPU consumption of timer_server

I've found stdlib's timer to burn CPU without good reason. Here's what
happens.

The problem is that it sleeps in milliseconds but computes time in
microseconds. And there is bug in code to compute milliseconds to
sleep. It computes microseconds difference between now and nearest
timer event and then does _truncating_ division by 1000. So on average
it sleeps 500 microseconds _less than needed_. On wakeup its checks do
I have timer tick that already occurred? No. Ok how much I need to
sleep ?  It does that bad computation again and gets 0
milliseconds. So next gen_server timeout happens right away only to
find we're still before closest timer tick and to decide to sleep 0
milliseconds again. And again and again.

This commit changes division to pick ceiling of ratio rather than
floor. So that we always sleep not less then difference between now
and closest event time.

getong/otp,lucafavatella/otp,lrascao/otp,vic/otp,msantos/otp,kvakvs/otp,NOMORECOFFEE/otp,matwey/otp,paladim/otp,falkevik/otp,vinoski/otp,yangchengjian/otp,lhslll/otp,bjorng/otp,marquisthunder/otp,paladim/otp,lhslll/otp,enikki/otp,platinumthinker/otp,cobusc/otp,ferd/otp,dumbbell/otp,jamesruan/otp,falkevik/otp,erlang/otp,RichMorin/otp,release-project/otp,theom/otp,matwey/otp,yangchengjian/otp,sammoth-wazoku/otp,neeraj9/otp,release-project/otp,platinumthinker/otp,goertzenator/otp,ferd/otp,electricimp/otp,kvakvs/otp,sammoth-wazoku/otp,stolen/otp,erlang/otp,cnbin/otp,jj1bdx/otp,lantti/otp,goertzenator/otp,krishnakumar4a4/otp,benoitc/otp-1,RJ/otp,electricimp/otp,fenollp/otp,tuncer/otp,haguenau/otp,lianghaivv/otp,Teino1978-Corp/erlang-otp,stolen/otp,awetzel/otp,massemanet/otp,derek121/otp,haguenau/otp,neeraj9/otp,RJ/otp,jinshana/otp,marquisthunder/otp,aboroska/otp,GinjaNinja32/otp,bsmr-erlang/otp,RaimoNiskanen/otp,dgud/otp,ahmedshafeeq/otp,jemsbhai/otp,RoadRunnr/otp,ader1990/otp,g-andrade/otp,bjorng/otp,bernardd/otp,sammoth-wazoku/otp,jj1bdx/otp,potatosalad/otp,release-project/otp,c-rack/otp,legoscia/otp,paladim/otp,VincentHHL/otp,release-project/otp,g-andrade/otp,RoadRunnr/otp,lightcyphers/otp,lucafavatella/otp,ahmedshafeeq/otp,basho/otp,ferd/otp,Teino1978-Corp/erlang-otp,platinumthinker/otp,massemanet/otp,lemenkov/otp,potatosalad/otp,getong/otp,bernardd/otp,vic/otp,erlang/otp,emacsmirror/erlang,g-andrade/otp,falkevik/otp,sammoth-wazoku/otp,RGafiyatullin/otp,ader1990/otp,beni55/otp,derek121/otp,jamesruan/otp,uabboli/otp,mujiatong/otp,paladim/otp,release-project/otp,benoitc/otp-1,tuncer/otp,weisslj/otp,lrascao/otp,lucafavatella/otp,sitexa/otp,entropiae/otp,bugs-erlang-org/otp,Teino1978-Corp/otp,RaimoNiskanen/otp,fenollp/otp,entropiae/otp,ferd/otp,RoadRunnr/otp,paladim/otp,potatosalad/otp,saleyn/otp,dumbbell/otp,mujiatong/otp,vinoski/otp,derek121/otp,NOMORECOFFEE/otp,falkevik/otp,entropiae/otp,platinumthinker/otp,uabboli/otp,Teino1978-Corp/erlang-otp,RichMorin/otp,bugs-erlang-org/otp,derek121/otp,klarna/otp,tuncer/otp,ahmedshafeeq/otp,beni55/otp,sdebnath/otp,vladdu/otp,bjorng/otp,vladdu/otp,rlipscombe/otp,weisslj/otp,RichMorin/otp,mikpe/otp,johanclaesson/otp,tuncer/otp,RaimoNiskanen/otp,fenollp/otp,lemenkov/otp,vladdu/otp,neeraj9/otp,potatosalad/otp,neeraj9/otp,NOMORECOFFEE/otp,GinjaNinja32/otp,ahmedshafeeq/otp,palas/otp,legoscia/otp,goertzenator/otp,isvilen/otp,bsmr-erlang/otp,falkevik/otp,sdebnath/otp,uabboli/otp,ferd/otp,benoitc/otp-1,RoadRunnr/otp,neeraj9/otp,lhslll/otp,ader1990/otp,erlang/otp,uabboli/otp,massemanet/otp,jamesruan/otp,g-andrade/otp,lantti/otp,bernardd/otp,RaimoNiskanen/otp,jj1bdx/otp,bsmr-erlang/otp,vinoski/otp,bugs-erlang-org/otp,RJ/otp,riverrun/otp,emile/otp,c-rack/otp,ferd/otp,RichMorin/otp,ader1990/otp,c-rack/otp,ader1990/otp,lhslll/otp,sitexa/otp,legoscia/otp,bernardd/otp,cobusc/otp,electricimp/otp,mikpe/otp,palas/otp,Teino1978-Corp/erlang-otp,Teino1978-Corp/erlang-otp,electricimp/otp,tuncer/otp,krishnakumar4a4/otp,potatosalad/otp,electricimp/otp,psyeugenic/otp,goertzenator/otp,dgud/otp,VincentHHL/otp,lantti/otp,kvakvs/otp,sitexa/otp,dgud/otp,erlang/otp,jj1bdx/otp,ader1990/otp,lrascao/otp,krishnakumar4a4/otp,emacsmirror/erlang,sitexa/otp,uabboli/otp,Teino1978-Corp/erlang-otp,massemanet/otp,gjaldon/otp,theom/otp,vladdu/otp,msantos/otp,emacsmirror/erlang,rlipscombe/otp,hairyhum/otp,RGafiyatullin/otp,entropiae/otp,enikki/otp,GinjaNinja32/otp,dgud/otp,bjorng/otp,marquisthunder/otp,bugs-erlang-org/otp,tuncer/otp,lucafavatella/otp,RaimoNiskanen/otp,lantti/otp,saleyn/otp,legoscia/otp,weisslj/otp,vic/otp,NOMORECOFFEE/otp,entropiae/otp,beni55/otp,c-rack/otp,Teino1978-Corp/otp,mujiatong/otp,RGafiyatullin/otp,jj1bdx/otp,matwey/otp,aboroska/otp,aboroska/otp,lantti/otp,johanclaesson/otp,uabboli/otp,jemsbhai/otp,cobusc/otp,msantos/otp,weisslj/otp,saleyn/otp,beni55/otp,benoitc/otp-1,release-project/otp,saleyn/otp,lantti/otp,marquisthunder/otp,rlipscombe/otp,paulcager/otp,riverrun/otp,erlang/otp,stolen/otp,jj1bdx/otp,dgud/otp,jj1bdx/otp,benoitc/otp-1,jamesruan/otp,enikki/otp,bjorng/otp,jemsbhai/otp,schlagert/otp,erlang/otp,mujiatong/otp,rlipscombe/otp,bernardd/otp,yangchengjian/otp,massemanet/otp,legoscia/otp,electricimp/otp,hairyhum/otp,ferd/otp,msantos/otp,mikpe/otp,mujiatong/otp,cobusc/otp,dumbbell/otp,krishnakumar4a4/otp,lianghaivv/otp,fenollp/otp,paulcager/otp,cnbin/otp,dumbbell/otp,vladdu/otp,g-andrade/otp,vinoski/otp,schlagert/otp,Teino1978-Corp/erlang-otp,getong/otp,theom/otp,bugs-erlang-org/otp,bjorng/otp,emacsmirror/erlang,haguenau/otp,legoscia/otp,klarna/otp,haguenau/otp,potatosalad/otp,tuncer/otp,beni55/otp,RaimoNiskanen/otp,yangchengjian/otp,mujiatong/otp,rlipscombe/otp,sitexa/otp,fenollp/otp,g-andrade/otp,potatosalad/otp,jinshana/otp,schlagert/otp,haguenau/otp,tuncer/otp,NOMORECOFFEE/otp,msantos/otp,RichMorin/otp,release-project/otp,saleyn/otp,fenollp/otp,rlipscombe/otp,enikki/otp,entropiae/otp,schlagert/otp,yangchengjian/otp,getong/otp,dumbbell/otp,riverrun/otp,aboroska/otp,VincentHHL/otp,jamesruan/otp,RJ/otp,bernardd/otp,kvakvs/otp,ferd/otp,lhslll/otp,lemenkov/otp,lrascao/otp,lightcyphers/otp,gjaldon/otp,riverrun/otp,sdebnath/otp,lhslll/otp,isvilen/otp,krishnakumar4a4/otp,RGafiyatullin/otp,psyeugenic/otp,jemsbhai/otp,rlipscombe/otp,basho/otp,emile/otp,cobusc/otp,palas/otp,saleyn/otp,stolen/otp,bjorng/otp,klarna/otp,getong/otp,krishnakumar4a4/otp,RichMorin/otp,erlang/otp,weisslj/otp,lightcyphers/otp,paulcager/otp,falkevik/otp,isvilen/otp,stolen/otp,gjaldon/otp,falkevik/otp,gjaldon/otp,haguenau/otp,lrascao/otp,weisslj/otp,VincentHHL/otp,benoitc/otp-1,matwey/otp,matwey/otp,jemsbhai/otp,kvakvs/otp,g-andrade/otp,schlagert/otp,RoadRunnr/otp,rlipscombe/otp,stolen/otp,ader1990/otp,Teino1978-Corp/otp,platinumthinker/otp,klarna/otp,emile/otp,fenollp/otp,NOMORECOFFEE/otp,sitexa/otp,vladdu/otp,lianghaivv/otp,lrascao/otp,bsmr-erlang/otp,bernardd/otp,awetzel/otp,gjaldon/otp,kvakvs/otp,vic/otp,bjorng/otp,vladdu/otp,GinjaNinja32/otp,bsmr-erlang/otp,enikki/otp,lucafavatella/otp,RJ/otp,dgud/otp,GinjaNinja32/otp,palas/otp,lucafavatella/otp,theom/otp,isvilen/otp,isvilen/otp,bernardd/otp,sitexa/otp,lrascao/otp,lrascao/otp,msantos/otp,isvilen/otp,cnbin/otp,massemanet/otp,marquisthunder/otp,benoitc/otp-1,derek121/otp,palas/otp,paulcager/otp,ahmedshafeeq/otp,jinshana/otp,entropiae/otp,neeraj9/otp,emile/otp,lemenkov/otp,kvakvs/otp,RGafiyatullin/otp,mikpe/otp,GinjaNinja32/otp,lianghaivv/otp,VincentHHL/otp,ahmedshafeeq/otp,psyeugenic/otp,VincentHHL/otp,ahmedshafeeq/otp,aboroska/otp,jj1bdx/otp,NOMORECOFFEE/otp,basho/otp,derek121/otp,psyeugenic/otp,cobusc/otp,lemenkov/otp,paladim/otp,emacsmirror/erlang,lrascao/otp,getong/otp,bsmr-erlang/otp,paulcager/otp,erlang/otp,jamesruan/otp,Teino1978-Corp/otp,gjaldon/otp,emacsmirror/erlang,dumbbell/otp,palas/otp,c-rack/otp,electricimp/otp,dgud/otp,lemenkov/otp,mikpe/otp,erlang/otp,yangchengjian/otp,cobusc/otp,rlipscombe/otp,matwey/otp,emile/otp,lightcyphers/otp,jemsbhai/otp,uabboli/otp,lianghaivv/otp,basho/otp,ferd/otp,Teino1978-Corp/otp,enikki/otp,aboroska/otp,RJ/otp,jamesruan/otp,vic/otp,isvilen/otp,theom/otp,bugs-erlang-org/otp,marquisthunder/otp,legoscia/otp,fenollp/otp,vladdu/otp,paladim/otp,johanclaesson/otp,getong/otp,aboroska/otp,riverrun/otp,cnbin/otp,RJ/otp,RichMorin/otp,weisslj/otp,RJ/otp,c-rack/otp,release-project/otp,aboroska/otp,bsmr-erlang/otp,sammoth-wazoku/otp,dumbbell/otp,theom/otp,cnbin/otp,electricimp/otp,derek121/otp,lemenkov/otp,riverrun/otp,goertzenator/otp,benoitc/otp-1,lucafavatella/otp,hairyhum/otp,krishnakumar4a4/otp,dumbbell/otp,lianghaivv/otp,platinumthinker/otp,RGafiyatullin/otp,bsmr-erlang/otp,vinoski/otp,bjorng/otp,emacsmirror/erlang,goertzenator/otp,paulcager/otp,stolen/otp,mikpe/otp,hairyhum/otp,klarna/otp,beni55/otp,jinshana/otp,potatosalad/otp,isvilen/otp,dgud/otp,Teino1978-Corp/otp,vinoski/otp,kvakvs/otp,cnbin/otp,hairyhum/otp,VincentHHL/otp,Teino1978-Corp/otp,schlagert/otp,bugs-erlang-org/otp,sammoth-wazoku/otp,emile/otp,sdebnath/otp,lianghaivv/otp,vinoski/otp,kvakvs/otp,uabboli/otp,msantos/otp,derek121/otp,emile/otp,enikki/otp,klarna/otp,RoadRunnr/otp,vic/otp,weisslj/otp,riverrun/otp,theom/otp,krishnakumar4a4/otp,sammoth-wazoku/otp,getong/otp,release-project/otp,ahmedshafeeq/otp,vladdu/otp,hairyhum/otp,mikpe/otp,emacsmirror/erlang,NOMORECOFFEE/otp,fenollp/otp,johanclaesson/otp,psyeugenic/otp,isvilen/otp,beni55/otp,cnbin/otp,lemenkov/otp,sammoth-wazoku/otp,neeraj9/otp,VincentHHL/otp,goertzenator/otp,paladim/otp,g-andrade/otp,jinshana/otp,c-rack/otp,sdebnath/otp,lhslll/otp,marquisthunder/otp,GinjaNinja32/otp,Teino1978-Corp/erlang-otp,RaimoNiskanen/otp,sdebnath/otp,RoadRunnr/otp,gjaldon/otp,neeraj9/otp,awetzel/otp,emile/otp,awetzel/otp,haguenau/otp,g-andrade/otp,paulcager/otp,c-rack/otp,yangchengjian/otp,jemsbhai/otp,enikki/otp,jinshana/otp,RGafiyatullin/otp,emacsmirror/erlang,johanclaesson/otp,electricimp/otp,basho/otp,rlipscombe/otp,vinoski/otp,lantti/otp,palas/otp,johanclaesson/otp,paulcager/otp,gjaldon/otp,klarna/otp,emacsmirror/erlang,johanclaesson/otp,palas/otp,hairyhum/otp,lightcyphers/otp,massemanet/otp,jamesruan/otp,theom/otp,RaimoNiskanen/otp,cnbin/otp,cobusc/otp,RGafiyatullin/otp,GinjaNinja32/otp,isvilen/otp,vic/otp,lantti/otp,bugs-erlang-org/otp,RoadRunnr/otp,marquisthunder/otp,weisslj/otp,schlagert/otp,johanclaesson/otp,getong/otp,msantos/otp,mujiatong/otp,matwey/otp,saleyn/otp,matwey/otp,dumbbell/otp,awetzel/otp,hairyhum/otp,tuncer/otp,lightcyphers/otp,entropiae/otp,RichMorin/otp,legoscia/otp,haguenau/otp,awetzel/otp,emile/otp,vic/otp,sitexa/otp,jj1bdx/otp,jemsbhai/otp,Teino1978-Corp/otp,ahmedshafeeq/otp,saleyn/otp,dumbbell/otp,sdebnath/otp,lhslll/otp,bernardd/otp,aboroska/otp,basho/otp,lightcyphers/otp,matwey/otp,mikpe/otp,platinumthinker/otp,psyeugenic/otp,schlagert/otp,bjorng/otp,vinoski/otp,falkevik/otp,sdebnath/otp,potatosalad/otp,riverrun/otp,basho/otp,beni55/otp,psyeugenic/otp,jinshana/otp,saleyn/otp,vinoski/otp,jj1bdx/otp,legoscia/otp,psyeugenic/otp,RoadRunnr/otp,awetzel/otp,mikpe/otp,goertzenator/otp,dgud/otp,basho/otp,g-andrade/otp,dgud/otp,lucafavatella/otp,falkevik/otp,bsmr-erlang/otp,awetzel/otp,RaimoNiskanen/otp,massemanet/otp,platinumthinker/otp,stolen/otp,goertzenator/otp,uabboli/otp,getong/otp,jinshana/otp,yangchengjian/otp,massemanet/otp,mikpe/otp,mujiatong/otp,lightcyphers/otp,klarna/otp,potatosalad/otp,basho/otp,lianghaivv/otp,ader1990/otp