Re: JMM - is this program data race free?

2022-10-23 Thread r r
) > } > > When (3) has observed the value written by (2) there is a happens-before > edge between (2) and (3). And due to the program order between (1)/(2) and > (3)/(4) and the transitive nature of happens-before, there is a > happens-before edge between (1) and (4). So the value&

JMM - is this program data race free?

2022-10-23 Thread r r
int x; volatile int v; write(x, 1) read(v) write(v, 1) read(x) Is that program data race free? On my eye it is not not because there is an execution that write(x, 1) and read(x) are not in happens-before relationship. -- You received this message because you are subscribed t

Re: volatile reads does happen before volatile write in JMM?

2022-09-15 Thread r r
Thanks! czw., 15 wrz 2022 o 12:40 Peter Veentjer napisał(a): > > > On Thu, Sep 15, 2022 at 11:43 AM r r wrote: > >> What about a such case: >> >> AtomicLong x; >> volatile boolean v; >> >> T1: >>v = true;

Re: volatile reads does happen before volatile write in JMM?

2022-09-15 Thread r r
means that T2 observer v == true because of happens-before *(1) -hb-> (2) -hb-> (3)*? środa, 14 września 2022 o 14:04:16 UTC+2 r r napisał(a): > Thanks > > śr., 14 wrz 2022, 13:26 użytkownik Peter Veentjer > napisał: > >> >> >> On Wed, Sep 14, 2022 at 1:51

Re: volatile reads does happen before volatile write in JMM?

2022-09-14 Thread r r
Thanks śr., 14 wrz 2022, 13:26 użytkownik Peter Veentjer napisał: > > > On Wed, Sep 14, 2022 at 1:51 PM r r wrote: > >> Hello, >> let's look for the following piece of code: >> >> int x; >> volatile boolean v; // v = false by default >&g

volatile reads does happen before volatile write in JMM?

2022-09-14 Thread r r
Hello, let's look for the following piece of code: int x; volatile boolean v; // v = false by default T1: x = 1; (1) v = true;(2) doSth(3) T2: doSth2(4) if (v) {} (5) When T2 observes that v == false in (5), does it mean that ther

Re: Java Memory Model, ConcurrencyHashMap and guarantee of iterator

2022-09-12 Thread r r
t;> e.g. >>>>> queues) >>>>> >>>>> Since the happens-before relation is transitive, there is a >>>>> happens-before edge between (1) and (4). >>>>> >>>>> On Mon, Sep 12, 2022 at 4:02 PM Alper Tekinalp >

Re: Java Memory Model, ConcurrencyHashMap and guarantee of iterator

2022-09-12 Thread r r
; >>>> From util.concurrent: >>>> >>>> > Actions in a thread prior to placing an object into any concurrent >>>> collection happen-before actions subsequent to the access or removal of >>>> that element from the collection in anothe

Re: Java Memory Model, ConcurrencyHashMap and guarantee of iterator

2022-09-12 Thread r r
another thread. >> >> So ether one of threads will print (true, true) I guess. >> >> On Mon, Sep 12, 2022, 3:42 PM Peter Veentjer >> wrote: >> >>> If T1 would run first, the content of the ConcurrentHashMap is (1,true), >>> and therefore t

Java Memory Model, ConcurrencyHashMap and guarantee of iterator

2022-09-12 Thread r r
Hello, let's look for the following piece of code: c = new ConcurrentHashMap(); T1: c.put(1, true); for (Boolean b : c.values()) { print(b); } T2: c.put(2, true); for (Boolean b : c.values()) { print(b); } Is it guaranteed by JMM that any thread (T1 or

Re: Resource to learn JIT compiler

2022-05-01 Thread r r
Thanks, watched it :). It is a great video that makes an overview of JVM / JIT optimizations. Do you know any material that are more in-depth, especially for inlining / devirtualization / escape analysis? piątek, 29 kwietnia 2022 o 16:56:40 UTC+2 Gil Tene napisał(a): > There are some some reco

Resource to learn JIT compiler

2022-04-29 Thread r r
Hello, do you know good resources to learn a bit about JIT compiler in Java? (Beyond reading JDK sources ;) ) -- 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

Re: Megamorphic virtual call optimization in Java

2022-02-08 Thread r r
:30:38 UTC+1 gregor...@gmail.com napisał(a): >> >>> which jvm? >>> >>> On Sat, Feb 5, 2022 at 6:26 AM r r wrote: >>> >>>> Hello, >>>> we know that there are some techniques that make virtual calls not so >>>> expensive in JVM like Inl

Resizable array, the fastest known approach

2022-02-08 Thread r r
Hello, 1. What is the fastest implementation of resizable array in Java? I know only one, that copies whole array to larger, new allocated array (offheap or noheap, do not care now). 2. I have one idea to implement (at least on Linux) no-copy, resizable array by using mremap syscall. Then, only

Re: Megamorphic virtual call optimization in Java

2022-02-05 Thread r r
JVM 11+ (OpenJDK / Zulu) sobota, 5 lutego 2022 o 12:30:38 UTC+1 gregor...@gmail.com napisał(a): > which jvm? > > On Sat, Feb 5, 2022 at 6:26 AM r r wrote: > >> Hello, >> we know that there are some techniques that make virtual calls not so >> expensive in JVM li

Megamorphic virtual call optimization in Java

2022-02-05 Thread r r
Hello, we know that there are some techniques that make virtual calls not so expensive in JVM like Inline Cache or Polymorphic Inline Cache. Let's consider the following situation: Base is an interface. public void f(Base[] b) { for(int i = 0; i < b.length; i++) { b[i].m();

Re: Thread safety of the shared piece of memory - Java Memory Model

2021-07-29 Thread r r
Thanks czwartek, 29 lipca 2021 o 20:30:46 UTC+2 alarm...@gmail.com napisał(a): > There is a happens before edge between calling the start method of a > thread and the thread running. > > On JMM level that is sufficient. > > On Thu, Jul 29, 2021, 18:47 r r wrote: > >&g

Thread safety of the shared piece of memory - Java Memory Model

2021-07-29 Thread r r
Hello, We have the simple pseudocode: void main(String[] args) { MemoryBuffer b = new MemoryBuffer(); // it is a off-heap native piece of memory allocated by malloc via JNI b.init(); // it just write some data to the memory buffer by JNI startThreadsThatReadsFromBuffer(b); // this fu