dev@grizzly.java.net

Re: CircularQueuePipeline ?

From: charlie hunt <charlie.hunt_at_sun.com>
Date: Wed, 24 Sep 2008 11:09:09 -0700

Jeanfrancois Arcand wrote:
> Salut,
>
> charlie hunt wrote:
>> Salut,
>>
>> I can add that information to the files.
>>
>> I don't like the duplicate code either. Hence my suggestion of
>> making CircularQueue & LinkedList plug-able.
>
> Ah sorry missed that.
>
>
>>
>> Did you ever do any comparisons of a "LinkedListPipeline extends
>> LinkedList" versus a "LinkedListPipeline" that uses a LinkedList as a
>> composite of LinkedListPipeline? If you happen to code this and try
>> it, could you put the LinkedList as the first non-static reference in
>> the list of fields for the LinkedListPipeline?
>
> Yes I did a while ago, based on your recommendation :-) That was in
> 2005 if I recall :-)
>
>>
>> If the "extends LinkedList" performs better, I think I know the
>> reason why.
>
> Yes it was performing a little better!

Ok, it's likely the way the fields are laid out in memory. The way
fields are laid out in memory differ when implemented as "extends
LinkedList" versus a composite of LinkedListPipeline. So, it's possible
the "extends LinkedList" is more CPU cache friendly. Knowing the
default way HotSpot lays out fields in memory, it's possible the
"extends LinkedList" is more CPU cache friendly.

Sounds like we need to figure out how to plug-in LinkedList or
CircularQueue as the data structure a concrete Pipeline extends.

charlie ...

>
> A+
>
> -- Jeanfrancois
>
>
>>
>> A+
>>
>> charlie ...
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> comment inline.
>>>
>>> charlie hunt wrote:
>>>> Salut,
>>>>
>>>> I'm attaching the CircularQueuePipeline. It's actually two files.
>>>> One is a CircularQueue data structure which supports the APIs
>>>> needed by the CircularQueuePipeline.
>>>>
>>>> I think we talked about this before at one time?
>>>>
>>>> I wonder if we should consider making CircularQueue or LinkedList
>>>> plug-able into the Pipeline?
>>>>
>>>> Since you're the Pipeline expert, would you like to do a quick
>>>> review of this implementation?
>>>>
>>>> A+
>>>>
>>>> charlie ...
>>>>
>>>> PS: I did some performance testing with this Pipeline versus the
>>>> LinkedListPipeline. The CircularQueuePipeline will perform better
>>>> under circumstances where there gets to be large number of entries
>>>> in the queue waiting to be executed. But, that's not a desire-able
>>>> situation. It also does slightly better on systems with small CPU
>>>> caches relative to the number of virtual processors (i.e. SPARC
>>>> T1/T2 processors). The underlying circular queue being an array is
>>>> more CPU cache friendly being an array than a set of linked list
>>>> nodes which could be scattered randomly throughout memory. But, on
>>>> traditional x86 architectures, it appears LinkedListPipeline does
>>>> slightly better than CircularQueuePipeline, especially if the
>>>> number of entries in the LinkedList is relatively small.
>>>
>>> Can you add that information inside the class description? This is
>>> quite interesting!
>>>
>>> One comment CircularQueuePipeline: your class share a lot of code
>>> (same code) with LinkedListPipeline. Would be nice if you can
>>> refactor both class and make then sharing the code. Because now both
>>> have the exact same code :-)
>>>
>>>>
>>>> charlie ...
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>