random gaps in hashedwheeltimer tiggers

"이희승 (Trustin Lee)" trustin at gmail.com
Mon Jan 31 00:55:52 EST 2011


I've just fixed this issue.  HashedWheelTimer now behaves in more robust
way when the scheduled task was put into a wrong slot in the wheel.

Thanks again Saibee for a very useful test case.

On 12/30/2010 07:13 AM, "이희승 (Trustin Lee)" wrote:
> It seems like the HashedWheelTimer missed the task once and caught it
> back up in the next turn.  By default, the number of ticks per wheel is
> 512, so it explains the 500ms delay.
> 
> Thanks for providing the test case.  Let me try to reproduce the problem
> and fix it.
> 
> On 12/29/2010 09:20 AM, Saibee Kollarmalil wrote:
>>
>>     @Test
>>     public void hashedWheelTimerTest() throws InterruptedException {
>>         final HashedWheelTimer timer = new HashedWheelTimer(1,
>> TimeUnit.MILLISECONDS);
>>         final long start = new Date().getTime();
>>         final CountDownLatch latch = new CountDownLatch(10);
>>         
>>         sheduleTaskWithDelay(timer, start, latch);
>>         latch.await();
>>     }
>>
>>     private void sheduleTaskWithDelay(final HashedWheelTimer timer, final
>> long start, final CountDownLatch latch) {
>>         timer.newTimeout(new TimerTask() {
>>             @Override
>>             public void run(Timeout timeout) throws Exception {
>>                 log.info("action time " + (new Date().getTime()-start));
>>                 latch.countDown();
>>                 sheduleTaskWithDelay(timer, start, latch);
>>             }}, 1, TimeUnit.MILLISECONDS);
>>     }
>>     
>>
>> The above test code produces the following out put. Notice the ~500ms gaps
>> introduced at random intervals. Any suggestions on how to resolve this? 
>>
>>
>> Dec 28, 2010 4:16:51 PM TimerPoolTest$3 run
>> INFO: action time 14
>> Dec 28, 2010 4:16:51 PM TimerPoolTest$3 run
>> INFO: action time 528
>> Dec 28, 2010 4:16:51 PM TimerPoolTest$3 run
>> INFO: action time 530
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1044
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1558
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1560
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1562
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1564
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1566
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1568
>> Dec 28, 2010 4:16:52 PM TimerPoolTest$3 run
>> INFO: action time 1593
> 

-- 
Trustin Lee, http://gleamynode.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20110131/4829564c/attachment.bin 


More information about the netty-users mailing list