Vladimir Ozerov created IGNITE-1615: ---------------------------------------
Summary: .Net: Perform AtomicLong.get() without JNI if possible. Key: IGNITE-1615 URL: https://issues.apache.org/jira/browse/IGNITE-1615 Project: Ignite Issue Type: Task Components: interop Affects Versions: ignite-1.4 Reporter: Vladimir Ozerov Fix For: ignite-1.5 Variables with atomic/interlocked semantics are frequently used in mostly-read scenarios. E.g. in spin-loops, non-blocking alogrithms, as regular volatiles, etc.. With current implementation we perform JNI call on every read which is too expensive, especially with poor Java performance when performing (native -> JVM) transition. We can optimize it with the following non-blocking algorithm: 1) Add atomic "stamp" field. 2) Add atomic "cached" field. 3) On any update: - Do the update; - Atomically increment the stamp; 4) On any read: - Read stamp (oldStamp); - Read cached value; - Read stamp again (newStamp); - if (oldStamp == newStamp == cache.stamp()), return cached value. - Otherwise perform real read through JNI and update cached value with a pair of (readValue + oldStamp); -- This message was sent by Atlassian JIRA (v6.3.4#6332)