You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by James Gan <ga...@gmail.com> on 2009/11/18 04:09:30 UTC

Is there use case for more scalable stack, queue, deque in Harmony?

Hi, dear all

I'm wondering if there is use case in Harmony for several scalable
components in Amino library. You can see its scalability curve in following
posts:

http://aminoprj.blogspot.com/2009/08/performance-of-amino-stack.html
http://aminoprj.blogspot.com/2009/08/lock-free-deque-in-amino-project.html
http://aminoprj.blogspot.com/2009/08/performance-of-amino-queue.html

If they can benefit users of Harmony, I'll like to contribute them to
Harmony project. Thanks!

-- 
Best Regards
James Gan
Current Project: Concurrent Building Block at
http://amino-cbbs.sourceforge.net/
Blog: http://ganzhi.blogspot.com

Re: Is there use case for more scalable stack, queue, deque in Harmony?

Posted by Joshua Bloch <jj...@google.com>.
James,

If these can be adapted to implement the JSR-166 APIs (completely), you'd
probably be best off working with Doug Lea (the JSR-166 benevolent dictator
for life) to integrate them into the JSR-166 codebase. This way, all users
of the j.u.c APIs (not just Harmony users) would benefit from them.

       Regards,

       Josh

On Tue, Nov 17, 2009 at 7:09 PM, James Gan <ga...@gmail.com> wrote:

> Hi, dear all
>
> I'm wondering if there is use case in Harmony for several scalable
> components in Amino library. You can see its scalability curve in following
> posts:
>
> http://aminoprj.blogspot.com/2009/08/performance-of-amino-stack.html
> http://aminoprj.blogspot.com/2009/08/lock-free-deque-in-amino-project.html
> http://aminoprj.blogspot.com/2009/08/performance-of-amino-queue.html
>
> If they can benefit users of Harmony, I'll like to contribute them to
> Harmony project. Thanks!
>
> --
> Best Regards
> James Gan
> Current Project: Concurrent Building Block at
> http://amino-cbbs.sourceforge.net/
> Blog: http://ganzhi.blogspot.com
>

Re: Is there use case for more scalable stack, queue, deque in Harmony?

Posted by Tim Ellison <t....@gmail.com>.
On 26/Nov/2009 08:59, James Gan wrote:
> Tim and Jesse,
> 
> Thanks for both of you comments and happy ThanksGiving day!
> 
> We'll talk with Doug Lea to see if it's suitable to put some of our
> components into JSR166 project. But notice there is a difference when
> compare goal of Amino library with JSR166 project. Amino project aims to
> provide really fast library, even if some functions are missing, while
> JSR166 must implement a rich set of feature.   For example,
> j.u.c.ConcurrentLinkedQueue will be much slower than our LockFreeQueue in
> future because it needs to support remove() in the middle of queue.
> 
> And yes, ReferenceQueue is a good example that our library can be helpful to
> Harmony project. That's a good example to the kind of use case that I'm
> looking for inside Harmony code. I'm not trying to replace a public API, but
> to increase scalability of Harmony code without hurting performance of
> single threaded program. For example, if a synchronized Stack is used in
> Harmony code, I'll like to try my ConcurrentStack and contribute it if the
> result is good.
> 
> I'll do more grep and let you know if I found any good use case. Thanks a
> lot!

I suspect you'd find more uses for a fast/scalable/lock-free Map rather
than queues and stacks.  Let us know what you find.

Regards,
Tim


Re: Is there use case for more scalable stack, queue, deque in Harmony?

Posted by James Gan <ga...@gmail.com>.
Tim and Jesse,

Thanks for both of you comments and happy ThanksGiving day!

We'll talk with Doug Lea to see if it's suitable to put some of our
components into JSR166 project. But notice there is a difference when
compare goal of Amino library with JSR166 project. Amino project aims to
provide really fast library, even if some functions are missing, while
JSR166 must implement a rich set of feature.   For example,
j.u.c.ConcurrentLinkedQueue will be much slower than our LockFreeQueue in
future because it needs to support remove() in the middle of queue.

And yes, ReferenceQueue is a good example that our library can be helpful to
Harmony project. That's a good example to the kind of use case that I'm
looking for inside Harmony code. I'm not trying to replace a public API, but
to increase scalability of Harmony code without hurting performance of
single threaded program. For example, if a synchronized Stack is used in
Harmony code, I'll like to try my ConcurrentStack and contribute it if the
result is good.

I'll do more grep and let you know if I found any good use case. Thanks a
lot!


On Thu, Nov 19, 2009 at 1:51 AM, Jesse Wilson <je...@google.com>wrote:

> On Wed, Nov 18, 2009 at 9:43 AM, Tim Ellison <t....@gmail.com>
> wrote:
>
> > You'd have to look a bit closer to see if these data
> > structures are used heavily,
> >
>
> Please avoid adding nonblocking behaviour where it isn't required by the
> API. Of the usages that Tim pointed out, all either don't require
> concurrency (XML, beans, Swing) or belong to java.util.concurrent, which
> isn't developed by Harmony.
>



-- 
Best Regards
James Gan
Current Project: Concurrent Building Block at
http://amino-cbbs.sourceforge.net/
Blog: http://ganzhi.blogspot.com

Re: Is there use case for more scalable stack, queue, deque in Harmony?

Posted by Jesse Wilson <je...@google.com>.
On Wed, Nov 18, 2009 at 9:43 AM, Tim Ellison <t....@gmail.com> wrote:

> You'd have to look a bit closer to see if these data
> structures are used heavily,
>

Please avoid adding nonblocking behaviour where it isn't required by the
API. Of the usages that Tim pointed out, all either don't require
concurrency (XML, beans, Swing) or belong to java.util.concurrent, which
isn't developed by Harmony.

Re: Is there use case for more scalable stack, queue, deque in Harmony?

Posted by Tim Ellison <t....@gmail.com>.
On 18/Nov/2009 03:09, James Gan wrote:
> I'm wondering if there is use case in Harmony for several scalable
> components in Amino library. You can see its scalability curve in following
> posts:
> 
> http://aminoprj.blogspot.com/2009/08/performance-of-amino-stack.html
> http://aminoprj.blogspot.com/2009/08/lock-free-deque-in-amino-project.html
> http://aminoprj.blogspot.com/2009/08/performance-of-amino-queue.html
> 
> If they can benefit users of Harmony, I'll like to contribute them to
> Harmony project. Thanks!

I suspect you have already found the obvious one, in ReferenceQueue
where I think we can get noticeable advantages from your scalable
implementation.

A simple grep of the code shows limited use of Stacks and Queues
elsewhere.  You'd have to look a bit closer to see if these data
structures are used heavily,

beans/src/main/java/java/beans/XMLDecoder.java
27:import java.util.Stack;

beans/src/main/java/org/apache/harmony/beans/Handler.java
23:import java.util.Stack;

swing/src/main/java/common/javax/swing/text/DefaultStyledDocument.java
32:import java.util.Stack;

swing/src/main/java/common/javax/swing/text/html/FormViewUtils.java
22:import java.util.Stack;

swing/src/main/java/common/javax/swing/text/html/HTMLDocument.java
30:import java.util.Stack;

swing/src/main/java/common/javax/swing/text/html/HTMLWriter.java
29:import java.util.Stack;

swing/src/main/java/common/javax/swing/text/html/parser/ParserCup.java
216:    java.util.Stack            stack,
307:    java.util.Stack            CUP$ParserCup$stack,

swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormRootOptionGroup.java
22:import java.util.Stack;

swing/src/main/java/common/org/apache/harmony/x/swing/text/rtf/DocumentRTFHandler.java
21:import java.util.Stack;

swing/src/main/java/common/org/apache/harmony/x/swing/text/rtf/RTFParser.java
5:import java.util.Stack;

swing/src/main/java/common/org/apache/harmony/x/swing/text/rtf/RTFParserTokenManager.java
4:import java.util.Stack;


concurrent/src/main/java/java/util/concurrent/BlockingQueue.java
10:import java.util.Queue;
13: * A {@link java.util.Queue} that additionally supports operations

concurrent/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
148: * {@link java.util.Queue} classes, and {@link LockSupport} blocking

concurrent/standard/src/main/java/java/util/concurrent/BlockingQueue.java
10:import java.util.Queue;
13: * A {@link java.util.Queue} that additionally supports operations

concurrent/standard/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
153: * {@link java.util.Queue} classes, and {@link LockSupport} blocking


Regards,
Tim