[jboss-jira] [JBoss JIRA] Commented: (JGRP-1051) TimeScheduler: replace use of ScheduledThreadPoolExecutor with ConcurrentSkipListMap

Bela Ban (JIRA) jira-events at lists.jboss.org
Fri Sep 18 03:03:49 EDT 2009


    [ https://jira.jboss.org/jira/browse/JGRP-1051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12486391#action_12486391 ] 

Bela Ban commented on JGRP-1051:
--------------------------------

[Brian]

I realized that my java.util.Timer suggestion can be just as easily implemented with a ScheduledThreadPoolExecutor with a single pool thread. The threading behavior is the same, which my gut tells me is a key thing -- no multiple pool threads waking up every time DelayQueue.take() is invoked and competing with app threads for the queue lock.

So, I implemented it, which was quite simple. Patch to rev 1.23.4.6 of TimeScheduler is attached. This is basically about 1/2 way to your ConcurrentSkipListMap approach, so if CSLM is a faster data structure moving to it when you move to JDK 6 should be straightforward.

I then took the result and integrated it with the source from the latest jar you sent me -- the one w/ the do/while loop. I also moved the do/while loop contents back inside the entry lock, a la what you said you'd done in your workspace. Trying to get to about what you've got on your system. 

Attachment is TimeScheduler.patch

> TimeScheduler: replace use of ScheduledThreadPoolExecutor with ConcurrentSkipListMap
> ------------------------------------------------------------------------------------
>
>                 Key: JGRP-1051
>                 URL: https://jira.jboss.org/jira/browse/JGRP-1051
>             Project: JGroups
>          Issue Type: Feature Request
>            Reporter: Bela Ban
>            Assignee: Bela Ban
>             Fix For: 2.9
>
>         Attachments: timer.zip, TimeScheduler.java, TimeScheduler.patch
>
>
> TimeScheduler currently extends ScheduledThreadPoolExecutor, which uses a DelayQueue for keeping an ordered list of tasks (ordered by their execution times).
> DelayQueue doesn't provide good speed, e.g. (IIRC) remove() requires a linear list scan.
> ConcurrentSkipListMap however provides O(log(n)) cost for get(), put(), remove() and containsKey(). Attached is a cursory impl of TimeScheduler based on ConcurrentSkipListMap. It is faster than the old version.
> Since ConcurrentSkipListMap requires JDK 1.6, we cannot use this in 2.6.x. It can be used in 3.0 only, or perhaps - after a discussion on the mailing list - in 2.9...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list