We're using Peter's chronicle in many of our deployments. Some other environments employ IPC over a more lightweight, bespoke solutions (using mmapped files too).
Not sure if I'm interpreting your statement correctly, but IPC over mmapped files regardless of whether you use bytebuffer or unsafe does work in Java.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Are you using any memory fences in your tests?
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
How are you obtaining the value on the reader side?
> Are you using any memory fences in your tests?No. How do I do that? I tried putLongVolatile. It did not work either :( I suspect is a visibility problem. One JVM gets the value cached in its CPU and don't get the write coming from the other JVM. Not sure how that can happen if I am using putLongVolatile. Passing null to its first argument. Hope someone can shed a light.
On Thursday, April 30, 2015 at 2:15:47 AM UTC-4, Wojciech Kudla wrote:
Are you using any memory fences in your tests?
On 30 Apr 2015 07:09, "Wojciech Kudla" <wojciec...@gmail.com> wrote:
We're using Peter's chronicle in many of our deployments. Some other environments employ IPC over a more lightweight, bespoke solutions (using mmapped files too).
Not sure if I'm interpreting your statement correctly, but IPC over mmapped files regardless of whether you use bytebuffer or unsafe does work in Java.
On 30 Apr 2015 05:14, <bob.tw...@gmail.com> wrote:
--So according to this blog post: http://psy-lob-saw.blogspot.com/2013/02/alignment-concurrency-and-torture-x86.htmlConcurrency over unsafe and aligned memory does NOT work in Java. According to my tests it works 90% of the time. I was close!What I am saying is:Two JVMs exchanging messages through a memory-mapped file, in other words, both are accessing the same unsafe memory address through the MappedByteBuffer:- First JVM writes a long to an aligned memory address (addressPointer % 8 == 0)- Second JVM never sees the update. It keeps trying to re-read the long from the address but keeps getting an old value. Forever.Is there a workaround to make this work or is it simply impossible to do it in Java?If it is impossible, how does someone go about synchronizing access to a memory mapped file in Java, so two processes can share it and use it appropriately as a transfer concurrent queue?
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
How are you obtaining the value on the reader side?
On 30 Apr 2015 07:38, <bob.tw...@gmail.com> wrote:
> Are you using any memory fences in your tests?No. How do I do that? I tried putLongVolatile. It did not work either :( I suspect is a visibility problem. One JVM gets the value cached in its CPU and don't get the write coming from the other JVM. Not sure how that can happen if I am using putLongVolatile. Passing null to its first argument. Hope someone can shed a light.
On Thursday, April 30, 2015 at 2:15:47 AM UTC-4, Wojciech Kudla wrote:
Are you using any memory fences in your tests?
On 30 Apr 2015 07:09, "Wojciech Kudla" <wojciec...@gmail.com> wrote:
We're using Peter's chronicle in many of our deployments. Some other environments employ IPC over a more lightweight, bespoke solutions (using mmapped files too).
Not sure if I'm interpreting your statement correctly, but IPC over mmapped files regardless of whether you use bytebuffer or unsafe does work in Java.
On 30 Apr 2015 05:14, <bob.tw...@gmail.com> wrote:
--So according to this blog post: http://psy-lob-saw.blogspot.com/2013/02/alignment-concurrency-and-torture-x86.htmlConcurrency over unsafe and aligned memory does NOT work in Java. According to my tests it works 90% of the time. I was close!What I am saying is:Two JVMs exchanging messages through a memory-mapped file, in other words, both are accessing the same unsafe memory address through the MappedByteBuffer:- First JVM writes a long to an aligned memory address (addressPointer % 8 == 0)- Second JVM never sees the update. It keeps trying to re-read the long from the address but keeps getting an old value. Forever.Is there a workaround to make this work or is it simply impossible to do it in Java?If it is impossible, how does someone go about synchronizing access to a memory mapped file in Java, so two processes can share it and use it appropriately as a transfer concurrent queue?
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
I'm pretty sure for many people on this list a few micros per handoff makes a difference.
Also, mmap-backed IPC gives you journalling for (almost) free.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
I've found it works perfectly well. You can see an many examples in the Agrona and Aeron projects. Simplest being the AtomicCounter class or even something more complicated like the ManyToOneRingBuffer.
https://github.com/real-logic/Agrona
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
Numa regions on the same machine are effectively distributed nodes. IPC is the best way to communicate between them if decoupled. This is why people typically use IPC. One big address space that spans multiple nodes is often the wrong solution.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
It you take the simplest thing that can possibility work then build from there is usually the best way to start. How about map a file in two processes as read and write. Then wrap the mapped buffer with my UnsafeBuffer class. Then write with putLongVolatile in one process and read with getLongVolatile in the other. Use offset 0 in the file for simplicity. You need to spin on the read to wait for the publication.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
Did you prepopulate the file with zeros to the correct size before mapping?
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
Nitsan,
Could you shed some more light on those issues?
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
I am old school => one node per cpu core, disregarding hyper-threading. A cpu core is the smallest unit of processing power, there is no scape. If two processes running on the same machine need to talk to each other as fast as possible, then pipelining (disruptor) is by far the fastest solution, you will agree with me on that. That would be the case of a feed talking to a strategy for example. For the less critical stuff you will probably have other machines doing the job in a true distributed system. There is only so much you can stuff on a single machine, no?
How can numa regions make that better in this situation?
Can you show the code? I don't think Thread.sleep () has any direct relationship to this and you don't need to "flush the cpu cache" (not quite right terminology, by the way). More likely there's some code generation problem that Thread.sleep () is perhaps perturbing.
Can you reproduce this if you run with Xint? Also try -client to use the C1 JIT compiler.
sent from my phone
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
As mentioned in the other thread, it may be worth nothing that unaligned read/write can be atomic so long as it doesn't cross a cacheline, depending on cpu.
sent from my phone
I remember reading slightly opposing opinions on word tearing.
One says it's not atomic, the other states that it would force atomicity by locking the bus.
I guess that depends on a particular cpu model. Is there any information on what to expect from different Intel CPUs?
Intel software dev manual talks about atomicity guarantees. I think atomicity of unaligned accesses within cacheline has been around for a while on Intel; what's fairly recent (Sandy Bridge+) is unaligned accesses being same speed as aligned, for most part. Store-load forwarding also works for them, for the most part, IIRC.
If you use lock'd instructions to read/write unaligned and cacheline spanning locations, then you do get atomicity due to bus arbitration - perhaps that's what you're thinking of? AFAIK, there's no automatic bus arbitration for plain unaligned accesses on intel.
sent from my phone
OK. I broke the return key on my keyboard executing the test one hundred times on Linux ubuntu: