You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/01/15 09:43:05 UTC
[GitHub] [rocketmq] zhongxiongzeng commented on pull request #3538: replace jdk Timer with netty HashedWheelTimer
zhongxiongzeng commented on pull request #3538:
URL: https://github.com/apache/rocketmq/pull/3538#issuecomment-1013652359
most effect is that improve the time to insert tasks, for example:
HashedWheelTimer and Timer both insert 1000000 task at the same time:
`
// HashedWheelTimer
for (int i = 0; i < 1000000; i++) {
hashedWheelTimer.newTimeout(timerTask, random.nextInt(1000), TimeUnit.MILLISECONDS);
}
`
`
// Timer
for (int i = 0; i < 1000000; i++) {
timer.schedule(task, random.nextInt(1000));
}
`
HashedWheelTimer cost 129 ms, but Timer cost 325 ms(My computer configuration is win10 + i5-8500 CPU + 16G ram)
because the implement of timer base on minHeap, The time complexity of each insert or delete is O(log(n)), but HashedWheelTimer is O(1);
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org