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

Brian Stansberry (JIRA) jira-events at lists.jboss.org
Thu Sep 17 10:27:39 EDT 2009


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

Brian Stansberry commented on JGRP-1051:
----------------------------------------

A couple comments:

1) If the thread taking tasks from the map sleeps the delay until the next task, rather than INTERVAL, it's more precise for low timeout tasks like bundled message transmission.

2) If you do 1) then in the schedule methods you need to test if a newly added task is scheduled before the earliest task. Otherwise you could have:

a) Schedule a MERGE task for 100 secs from now.
b) processing thread goes to sleep for 100 secs.
c) Schedule a message bundle for 30 ms from now.
d) processing thread wakes up 100 secs later.

3) The processing thread can call Task.isCancelled() and not pass the task to the pool if so. Passing the task to the pool requires taking a lock, blocking until a pool thread is available etc.

> 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: TimeScheduler.java
>
>
> 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