HashedWheelTimer and changing system time
Christian Migowski
chrismfwrd at gmail.com
Thu Jun 24 02:08:36 EDT 2010
Hi,
IMHO it is a strange test to modify the system time for a minute and
wondering why a timer with 30 seconds timeout gets confused, but ok.
Some time ago I had problems with the HashedWheelTimer (it was _quite_
inaccurate), the reason seemed to be some Java Windows issues on
multicore system, so then the implementation was changed. See this
thread:
http://netty.markmail.org/message/d32svwwlmbke6jm6
regards,
christian!
On Thu, Jun 24, 2010 at 7:41 AM, Evgeniy Devyatyh <devyatyh at gmail.com> wrote:
>
> Hello! In advance sorry for my english.
>
> I'm use Netty for our server working on Windows ( :-( ) and *nix systems.
> On Windows i find the next behavior: if change system clock (example, minus
> minute and plus minute) HashedWheelTimer timer may not run.
>
> public class TimerTest {
>
> public static void main(String[] args) throws Exception{
> Timer t = new HashedWheelTimer();
> Timeout to = t.newTimeout(new TimerTask() {
> public void run(Timeout timeout) throws Exception {
> System.out.println("Bingo!");
> System.exit(0);
> }
> }, 30, TimeUnit.SECONDS);
>
> for (;;) {
> System.out.println(to);
> Thread.sleep(1000);
> }
> }
> }
>
> Output:
> HashedWheelTimeout(deadline: 29984 ms later, )
> [skipped]
> HashedWheelTimeout(deadline: 23984 ms later, )
> HashedWheelTimeout(deadline: 22984 ms later, )
> [now i change system time: minus one minute]
> HashedWheelTimeout(deadline: 83562 ms later, )
> HashedWheelTimeout(deadline: 82562 ms later, )
> [skipped]
> HashedWheelTimeout(deadline: 75562 ms later, )
> HashedWheelTimeout(deadline: 74562 ms later, )
> [again change system time: plus one minute]
> HashedWheelTimeout(deadline: 15344 ms later, )
> HashedWheelTimeout(deadline: 14344 ms later, )
> [skipped]
> HashedWheelTimeout(deadline: 1344 ms later, )
> HashedWheelTimeout(deadline: 344 ms later, )
> HashedWheelTimeout(deadline: 656 ms ago, )
> HashedWheelTimeout(deadline: 1656 ms ago, )
> [and so on]
>
> No Bingo!
>
> Why to not use System.nanoTime() instead System.currentTimeMillis() in
> HashedWheelTimer?
> It's solved problem in my tests.
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/HashedWheelTimer-and-changing-system-time-tp5216326p5216326.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
More information about the netty-users
mailing list