You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Matt Sicker <bo...@gmail.com> on 2016/12/18 01:10:23 UTC

Are we using spin loops anywhere?

I thought we were using it in AppenderControlArraySet for example, but it
doesn't look like it really matches the idea. I've been reading through all
the JEPs in JDK9 to see if there's anything else useful we haven't already
marked in our epic <https://issues.apache.org/jira/browse/LOG4J2-1564>, and
I found Thread.onSpinWait() <http://openjdk.java.net/jeps/285> which looked
useful, but I'm not sure of anywhere we could use it.

-- 
Matt Sicker <bo...@gmail.com>

Re: Are we using spin loops anywhere?

Posted by Matt Sicker <bo...@gmail.com>.
I've gone and submitted feature requests to LMAX, Conversant, and JCTools
to add support for it. I don't think we're using any other libraries where
this would be relevant.

On 18 December 2016 at 11:32, Matt Sicker <bo...@gmail.com> wrote:

> I see they're using spin locks in Conversant Disruptor: <
> https://github.com/conversant/disruptor/blob/master/src/main/java/com/
> conversantmedia/util/concurrent/AbstractSpinningCondition.java>. I'd
> imagine something similar is in JCTools and LMAX, so it would be useful to
> request support for this upstream.
>
> From what I can tell, LinkedTransferQueue in JDK9 doesn't rely on spin
> locks as it's using an interesting algorithm whose documentation is
> literally half the source file. I see that they've updated it to use
> VarHandles instead of Unsafe, though, so there's that, too.
>
> On 18 December 2016 at 06:43, Remko Popma <re...@gmail.com> wrote:
>
>>
>>
>>
>> Sent from my iPhone
>> On 18 Dec 2016, at 13:05, Remko Popma <re...@gmail.com> wrote:
>>
>> I don't think we use spin locks in production code anywhere.
>>
>> The latency test has a wait strategy interface and one of the
>> implementations is spinning. I need to check the comments but not sure if I
>> used that strategy for the latency tests for the garbage free performance
>> page.
>>
>>
>> I just noticed that Gil Tene authored JEP 285. He is also the author of
>> the Pacer class used in our latency test (https://github.com/apache/log
>> ging-log4j2/blob/master/log4j-core/src/test/java/org/apache/
>> logging/log4j/core/async/perftest/ResponseTimeTest.java)
>>
>> Our test checks the number of cores, and if sufficient, it uses the NoOpIdleStrategy
>> (spin wait). The alternative is yielding the thread, but who knows when the
>> thread gets scheduled again (and on which core - a different core means the
>> cache is cold). For latency measurements of short duration, the hope is
>> that a spinning wait introduces less noise.
>>
>>
>>
>> Sent from my iPhone
>>
>> On 18 Dec 2016, at 10:10, Matt Sicker <bo...@gmail.com> wrote:
>>
>> I thought we were using it in AppenderControlArraySet for example, but it
>> doesn't look like it really matches the idea. I've been reading through all
>> the JEPs in JDK9 to see if there's anything else useful we haven't already
>> marked in our epic <https://issues.apache.org/jira/browse/LOG4J2-1564>,
>> and I found Thread.onSpinWait() <http://openjdk.java.net/jeps/285> which
>> looked useful, but I'm not sure of anywhere we could use it.
>>
>> --
>> Matt Sicker <bo...@gmail.com>
>>
>>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Are we using spin loops anywhere?

Posted by Matt Sicker <bo...@gmail.com>.
I see they're using spin locks in Conversant Disruptor: <
https://github.com/conversant/disruptor/blob/master/src/main/java/com/conversantmedia/util/concurrent/AbstractSpinningCondition.java>.
I'd imagine something similar is in JCTools and LMAX, so it would be useful
to request support for this upstream.

From what I can tell, LinkedTransferQueue in JDK9 doesn't rely on spin
locks as it's using an interesting algorithm whose documentation is
literally half the source file. I see that they've updated it to use
VarHandles instead of Unsafe, though, so there's that, too.

On 18 December 2016 at 06:43, Remko Popma <re...@gmail.com> wrote:

>
>
>
> Sent from my iPhone
> On 18 Dec 2016, at 13:05, Remko Popma <re...@gmail.com> wrote:
>
> I don't think we use spin locks in production code anywhere.
>
> The latency test has a wait strategy interface and one of the
> implementations is spinning. I need to check the comments but not sure if I
> used that strategy for the latency tests for the garbage free performance
> page.
>
>
> I just noticed that Gil Tene authored JEP 285. He is also the author of
> the Pacer class used in our latency test (https://github.com/apache/
> logging-log4j2/blob/master/log4j-core/src/test/java/org/
> apache/logging/log4j/core/async/perftest/ResponseTimeTest.java)
>
> Our test checks the number of cores, and if sufficient, it uses the NoOpIdleStrategy
> (spin wait). The alternative is yielding the thread, but who knows when the
> thread gets scheduled again (and on which core - a different core means the
> cache is cold). For latency measurements of short duration, the hope is
> that a spinning wait introduces less noise.
>
>
>
> Sent from my iPhone
>
> On 18 Dec 2016, at 10:10, Matt Sicker <bo...@gmail.com> wrote:
>
> I thought we were using it in AppenderControlArraySet for example, but it
> doesn't look like it really matches the idea. I've been reading through all
> the JEPs in JDK9 to see if there's anything else useful we haven't already
> marked in our epic <https://issues.apache.org/jira/browse/LOG4J2-1564>,
> and I found Thread.onSpinWait() <http://openjdk.java.net/jeps/285> which
> looked useful, but I'm not sure of anywhere we could use it.
>
> --
> Matt Sicker <bo...@gmail.com>
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: Are we using spin loops anywhere?

Posted by Remko Popma <re...@gmail.com>.


Sent from my iPhone
> On 18 Dec 2016, at 13:05, Remko Popma <re...@gmail.com> wrote:
> 
> I don't think we use spin locks in production code anywhere. 
> 
> The latency test has a wait strategy interface and one of the implementations is spinning. I need to check the comments but not sure if I used that strategy for the latency tests for the garbage free performance page. 

I just noticed that Gil Tene authored JEP 285. He is also the author of the Pacer class used in our latency test (https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java)

Our test checks the number of cores, and if sufficient, it uses the NoOpIdleStrategy (spin wait). The alternative is yielding the thread, but who knows when the thread gets scheduled again (and on which core - a different core means the cache is cold). For latency measurements of short duration, the hope is that a spinning wait introduces less noise. 


> 
> Sent from my iPhone
> 
>> On 18 Dec 2016, at 10:10, Matt Sicker <bo...@gmail.com> wrote:
>> 
>> I thought we were using it in AppenderControlArraySet for example, but it doesn't look like it really matches the idea. I've been reading through all the JEPs in JDK9 to see if there's anything else useful we haven't already marked in our epic <https://issues.apache.org/jira/browse/LOG4J2-1564>, and I found Thread.onSpinWait() <http://openjdk.java.net/jeps/285> which looked useful, but I'm not sure of anywhere we could use it.
>> 
>> -- 
>> Matt Sicker <bo...@gmail.com>

Re: Are we using spin loops anywhere?

Posted by Remko Popma <re...@gmail.com>.
I don't think we use spin locks in production code anywhere. 

The latency test has a wait strategy interface and one of the implementations is spinning. I need to check the comments but not sure if I used that strategy for the latency tests for the garbage free performance page. 

Sent from my iPhone

> On 18 Dec 2016, at 10:10, Matt Sicker <bo...@gmail.com> wrote:
> 
> I thought we were using it in AppenderControlArraySet for example, but it doesn't look like it really matches the idea. I've been reading through all the JEPs in JDK9 to see if there's anything else useful we haven't already marked in our epic <https://issues.apache.org/jira/browse/LOG4J2-1564>, and I found Thread.onSpinWait() <http://openjdk.java.net/jeps/285> which looked useful, but I'm not sure of anywhere we could use it.
> 
> -- 
> Matt Sicker <bo...@gmail.com>