FAQ
I was looking at Martin Thompson's implementation of a single producer and
single consumer queue (Java) at:
https://github.com/mjpt777/examples/tree/master/src/java/uk/co/real_logic/queues

I saw Go's atomic.storePointer and atomic.loadPointer. Seems like a
combination of the two can be used to implement Java's volatile semantics.
Is there a way I could achieve what lazySet/ putOrderedObject does?

I am planning to write a cache where a single goroutine locked to an OS
thread writes to the cache and other goroutines read from the cache. A
lazySet / putOrderedObject equivalent could be a good optimization here. I
know I can use a mutex or RW mutex instead. I want to optimize for the
single writer use case to just see the improvements possible if only for
academic reasons.

Thanks,
rajiv

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Tamás Gulácsi at Jun 27, 2013 at 4:42 am
    Why not use channels?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rajiv Kurian at Jun 27, 2013 at 4:43 am
    For academic reasons only :)
    On Wednesday, June 26, 2013 9:42:02 PM UTC-7, Tamás Gulácsi wrote:

    Why not use channels?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dmitry Vyukov at Jun 27, 2013 at 8:35 am

    On Thu, Jun 27, 2013 at 7:58 AM, Rajiv Kurian wrote:
    I was looking at Martin Thompson's implementation of a single producer and
    single consumer queue (Java) at:
    https://github.com/mjpt777/examples/tree/master/src/java/uk/co/real_logic/queues

    I saw Go's atomic.storePointer and atomic.loadPointer. Seems like a
    combination of the two can be used to implement Java's volatile semantics.
    Is there a way I could achieve what lazySet/ putOrderedObject does?

    I am planning to write a cache where a single goroutine locked to an OS
    thread writes to the cache and other goroutines read from the cache. A
    lazySet / putOrderedObject equivalent could be a good optimization here. I
    know I can use a mutex or RW mutex instead. I want to optimize for the
    single writer use case to just see the improvements possible if only for
    academic reasons.

    Go does not provide any kind of "relaxed" atomics, one sequentially
    consistent atomics. For academic reasons you may patch sync/atomic
    locally, all you need is to replace XCHG in atomic.Store with MOV.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rajiv Kurian at Jun 27, 2013 at 5:14 pm
    Thanks Dmitry, I'll try to do that.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rajiv Kurian at Jun 27, 2013 at 10:09 pm
    Hey Dmitry:

    If I wanted to write my own storeLazyPointer function instead of updating
    storePointer would updating go/src/pkg/sync/atomic/doc.go
    and go/src/pkg/sync/atomic/asm_amd64.s be enough (I am running on amd64)?

    Thanks,
    Rajiv
    On Thursday, June 27, 2013 10:14:30 AM UTC-7, Rajiv Kurian wrote:

    Thanks Dmitry, I'll try to do that.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dmitry Vyukov at Jun 28, 2013 at 10:11 am

    On Fri, Jun 28, 2013 at 2:09 AM, Rajiv Kurian wrote:
    Hey Dmitry:

    If I wanted to write my own storeLazyPointer function instead of updating
    storePointer would updating go/src/pkg/sync/atomic/doc.go and
    go/src/pkg/sync/atomic/asm_amd64.s be enough (I am running on amd64)?
    Yes, this should be enough.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Francis at Dec 23, 2014 at 3:04 pm
    Hey Rajiv,

    If you are still looking at implementing Martin Thompson's spec queue I
    have implemented a few here

    https://github.com/fmstephe/flib

    Inside the queues/spsc directory are a handful of queues based on Martin's
    Java code.

    As a side note. I have found that using the LoadInt64/StoreInt64 is roughly
    as performant as the naked MOV based lazySet(...). This is only true when
    we start to use the PAUSE/RDTSC instructions for contention reducing
    back-off.

    Should also note, that the LoadInt64/StoreInt64 are not at all guaranteed
    to be sufficient according to the memory model.

    F
    On Thursday, 27 June 2013 04:58:39 UTC+1, Rajiv Kurian wrote:

    I was looking at Martin Thompson's implementation of a single producer and
    single consumer queue (Java) at:
    https://github.com/mjpt777/examples/tree/master/src/java/uk/co/real_logic/queues

    I saw Go's atomic.storePointer and atomic.loadPointer. Seems like a
    combination of the two can be used to implement Java's volatile semantics.
    Is there a way I could achieve what lazySet/ putOrderedObject does?

    I am planning to write a cache where a single goroutine locked to an OS
    thread writes to the cache and other goroutines read from the cache. A
    lazySet / putOrderedObject equivalent could be a good optimization here. I
    know I can use a mutex or RW mutex instead. I want to optimize for the
    single writer use case to just see the improvements possible if only for
    academic reasons.

    Thanks,
    rajiv
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 27, '13 at 3:58a
activeDec 23, '14 at 3:04p
posts8
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase