Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread John Hening
Gil and Vladimir, thanks a lot for your time and explanation. This discussion was very fruitful, at least for me. W dniu niedziela, 18 listopada 2018 19:35:30 UTC+1 użytkownik Vladimir Sitnikov napisał: > > Jean-Philippe>is a write to value but no read of this value inside the > same thread,

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-17 Thread John Hening
Gil, thank you. In the docs it is written Retrievals reflect the results of the most recently *completed* update > operations holding upon their onset. (More formally, an update operation > for a given key bears a *happens-before* relation with any (non-null) > retrieval for that key

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-17 Thread John Hening
in other cases where non-final fields are involved, e.g. if p.x was a > Foo with a non-final field y with a getter, p.x.getY() may return an > uninitialized value after the get() returns a non-null p. > > On Friday, November 16, 2018 at 3:59:47 AM UTC-8, John Hening wrote: >> &g

Happens before between putting and getting from and to ConcurrentHashMap

2018-11-16 Thread John Hening
Hello, let's look at: class P { public String x; } ConcurrentHashMap x = new ConcurrentHashMap<>(); new Thread(() -> { // Thread 1 x.put(1, new String("x")); // 1 }).start(); new Thread(() -> { // Thread 2

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread John Hening
quot;doers contain different > objects": your code submits executions of functions using the same x member > of xs to all doers, and it is only the guaranteed serialization in your > chosen executor implementation that prevents x,f()s from racing on the same > x... > > O

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread John Hening
> > (1) should happen before "executor.execute()" (because they are on the > same thread), > It does not matter that they are executed on the same thread. I do not see cause here to HB relation was set up. -- You received this message because you are subscribed to the Google Groups

Re: JMM- conservative and formal point of view.

2018-05-18 Thread John Hening
Aleksey, thanks for your explanation. By the way, your presentation (I mean slides) is great- when it comes to the content and not only :-). W dniu środa, 16 maja 2018 19:33:22 UTC+2 użytkownik John Hening napisał: > > The following picture comes from: > https://shipilev.net/blog

Re: JMM- conservative and formal point of view.

2018-05-16 Thread John Hening
environment. In my example I see nothing prevents reordering. a = 42 a = 41 ready = true a = 43 is equivalent to a = 41; a = 42; ready = true; a = 43; W dniu środa, 16 maja 2018 19:49:04 UTC+2 użytkownik Aleksey Shipilev napisał: > > On 05/16/2018 07:33 PM, John Hening wrote: >

JMM- conservative and formal point of view.

2018-05-16 Thread John Hening
The following picture comes from: https://shipilev.net/blog/2014/jmm-pragmatics/ As I understand this slide points that JMM does not constitute that a volatile write does not work as a (Load/Store)Store barrier, and it doesn't in

Re: Throughput test of OpenHFT networking

2018-05-12 Thread John Hening
Why do you think that I have a production system? I do it for learning purpose. W dniu sobota, 12 maja 2018 21:59:53 UTC+2 użytkownik Greg Young napisał: > > Will your production system be running over loopback? > > On Sun, May 13, 2018 at 1:59 AM, John Hening <goci...@gmail

Throughput test of OpenHFT networking

2018-05-12 Thread John Hening
Hello, I am trying to examine a throughput of OpenHFT networking in version 1.12.2 to compare it with my toy. My test works in the following way: I have few concurrent clients that send (by loopback) to the server (written with OpenHFT networking) 131`072 messages of size 4KB and

Re: Experiments with send in Linux

2018-05-07 Thread John Hening
Thanks Avi, > The send doesn't wait, but the kernel has to serve both the send side and > the receive side, and if they happen to run on the same CPU and possibly in > the same thread, then you'll see them in the flame graph for that CPU or > thread. Ok. I didn't notice that I create a

Re: Nanotrusting the Nanotime and amortization.

2018-04-25 Thread John Hening
So by amortization you mean just: In reality volatile write in relation to whole execution negligible. yes? -- 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

Nanotrusting the Nanotime and amortization.

2018-04-24 Thread John Hening
I'm reading the great article from https://shipilev.net/blog/2014/nanotrusting-nanotime/ (thanks Aleksey! :)) and I am not sure whether I understand correctly that. Firstly, it is compared performance of plain and volatile writes: Benchmark Mode Samples Mean Mean error Units

Analysis of perf sched for simple server.

2018-04-23 Thread John Hening
Hello, 1. I have a simple one-threaded tcp server written in Java. I try to measure its receive-and-process-response latency. More preceisely, the client sends (by loopback) the 128-bytes message with a timestamp in the header. The server receives a message, reads a content byte by byte and

Re: Exclusive core for a process, is it reasonable?

2018-04-10 Thread John Hening
Thanks for your responses W dniu niedziela, 8 kwietnia 2018 14:51:52 UTC+2 użytkownik John Hening napisał: > > Hello, > > I've read about thread affinity and I see that it is popular in > high-performance-libraries (for example > https://github.com/OpenHFT/Java-Thread-Affin

Re: garbage-free java.nio

2018-03-12 Thread John Hening
Thanks! :) W dniu niedziela, 11 marca 2018 21:25:32 UTC+1 użytkownik John Hening napisał: > > Hello, > > recently I am interested in non-blokcing java api for networking. It seems > to be great. However, I would like to implement garbage-free solution. I am > trying to do it

garbage-free java.nio

2018-03-11 Thread John Hening
Hello, recently I am interested in non-blokcing java api for networking. It seems to be great. However, I would like to implement garbage-free solution. I am trying to do it only for learning purpose (I know that I don't implement a "better" solution). Especially, my solution is going to be

Re: Looking at reordering memory operations

2018-03-11 Thread John Hening
Gil, thanks for your explanation. W dniu piątek, 9 marca 2018 23:20:37 UTC+1 użytkownik John Hening napisał: > > > executor = Executors.newFixedThreadPool(16); > while(true) { > SocketChannel connection = serverSocketChannel.accept(); >

Re: Looking at reordering memory operations

2018-03-10 Thread John Hening
U can execute that as: mov , 3 sfence ? I know that: mov , 1 mov , 2 mov , 3 x86-CPU can optimizied it legally. W dniu piątek, 9 marca 2018 23:20:37 UTC+1 użytkownik John Hening napisał: > > > executor = Executors.newFixedThreadPool(16); > while(true)

Re: Looking at reordering memory operations

2018-03-10 Thread John Hening
; to the main memory. W dniu piątek, 9 marca 2018 23:20:37 UTC+1 użytkownik John Hening napisał: > > > executor = Executors.newFixedThreadPool(16); > while(true) { > SocketChannel connection = serverSocketChannel.accept(); > connection.configueBlock

Looking at reordering memory operations

2018-03-09 Thread John Hening
executor = Executors.newFixedThreadPool(16); while(true) { SocketChannel connection = serverSocketChannel.accept(); connection.configueBlocking(false); executor.execute(() -> writeTask(connection)); } void writeTask(SocketChannel s){

String.interning is surprisingly cpu-consuming.

2018-02-27 Thread John Hening
Hello! I have the very simple Utils function: public static Unsafe getUnsafe(){ Field f = Unsafe.class.getDeclaredField("theUnsafe"); f.setAccessible(true); return (Unsafe) f.get(null); } And, as it turned out from my analysis with perf it is a bottleneck in my "scheme" of

Re: JITed very simple method.

2018-02-05 Thread John Hening
niedziela, 4 lutego 2018 00:31:28 UTC+1 użytkownik John Hening napisał: > > public static int dontOptimize; > > > public static int simple(){ > return dontOptimize; > } > > And JITed version of that: > > > 0x7fdc75112aa0: mov%eax,-0x14000(%rsp)

Re: JITed very simple method.

2018-02-04 Thread John Hening
Feb 2018, at 23:31, John Hening <goci...@gmail.com > > wrote: > > public static int dontOptimize; > > > public static int simple(){ > return dontOptimize; > } > > And JITed version of that: > > > 0x7fdc75112aa0: mov%eax,-0x14000(%rsp) > 0x

Re: allocation memory in Java

2017-11-20 Thread John Hening
> > With perf. OpenJDK might need to be configured with debug symbols: > --with-native-debug-symbols=internal > @Aleksey, when I try to configure openjdk8 with that option I get an error: configure: error: unrecognized options: --with-native-debug-symbols Exactly, I I downloaded jdk8u and I

Re: allocation memory in Java

2017-11-18 Thread John Hening
Thanks for your replies :) @Aleksey, how to get that? - 17.12% 0.00% org.openjdk.All perf-31615.map - 0x7faaa3b2d125 - 16.59% OptoRuntime::new_instance_C - 11.49% InstanceKlass::allocate_instance 2.33% BlahBlahBlahCollectedHeap::mem_allocate < entry

allocation memory in Java

2017-11-17 Thread John Hening
I am reading source of HotSpot sourcode src/share/vm/memory/allocation.hpp and I see: // All classes in the virtual machine must be subclassed > // by one of the following allocation classes: > // > // For objects allocated in the resource area (see resourceArea.hpp). > // - ResourceObj > // >

Master thesis in mechanical sympathy, Java performance.

2017-11-16 Thread John Hening
Hi, I know that there is a lot of experts in Java oriented on "mechanical sympathy" here. I am very interested in that subject- however I am a beginner. However, I am not clueless about it. I'm a bit familiar with the processor architecture, lock-free, garbage free and so on. My question

Executing thread by JVM.

2017-11-12 Thread John Hening
Hello, I would like to ask for threads in Java. As we know, JVM uses system threads (native threads). So, for example it uses Linux threads. In simplification a thread is a stack + piece of code to execute. Let's consider: Thread t = new Thread(() -> {`any_code`}); t.start(); t.join();

Re: sun.misc.Unsafe.getAndAddInt implementation, question.

2017-10-17 Thread John Hening
shaping, > folding-together, and completely eliminating big parts off your apparent > bytecode instructions. And the JIT will do all those as long as it can > prove that the transformations are allowed. > > On Monday, October 16, 2017 at 3:30:13 PM UTC+1, John Hening wrote: >>

Re: sun.misc.Unsafe.getAndAddInt implementation, question.

2017-10-16 Thread John Hening
out of the loop. > > If this valid optimization happened, the resulting code would get stuck in > an infinite loop if another thread modified the field between the read of > curr and the compareAndSwapInt call, and that is obviously not the intended > behavior

sun.misc.Unsafe.getAndAddInt implementation, question.

2017-10-14 Thread John Hening
Hello it is an implementation from sun.misc.Unsafe. public final int getAndAddInt(Object ptr, long offset, int value) { int curr; do { curr = this.getIntVolatile(ptr, offset); (1) } while(!this.compareAndSwapInt(ptr, offset, curr, curr + value)); (2) return curr;} Why there is