From 6660e833564e5a902c3c2d05ad59a3353ac1624e Mon Sep 17 00:00:00 2001 From: cotton-ben Date: Sat, 2 May 2020 17:44:01 -0400 Subject: [PATCH] Stub for a Set of Tests to drive Chronicle's potential to accommodate highly pedantic isolation zealots within its ACID transactions capability. Top priority ... does Chronicle have the ambition to accommodate the dirty read intolerant? --- .../chronicle/map/acid/BondVOInterface.java | 93 +++++ .../map/acid/ChronicleAcidIsolation.java | 18 + .../acid/ChronicleAcidIsolationGovernor.java | 355 ++++++++++++++++++ .../fromdocs/acid/DirtyReadIntolerant.java | 122 ++++++ .../map/fromdocs/acid/DirtyReadOffender.java | 45 +++ .../map/fromdocs/acid/DirtyReadVictim.java | 46 +++ .../pingpong_latency/PingPongCASLeft.java | 27 +- .../pingpong_latency/PingPongCASRight.java | 2 +- 8 files changed, 698 insertions(+), 10 deletions(-) create mode 100644 src/main/java/net/openhft/chronicle/map/acid/BondVOInterface.java create mode 100644 src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolation.java create mode 100644 src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolationGovernor.java create mode 100644 src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadIntolerant.java create mode 100644 src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadOffender.java create mode 100644 src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadVictim.java diff --git a/src/main/java/net/openhft/chronicle/map/acid/BondVOInterface.java b/src/main/java/net/openhft/chronicle/map/acid/BondVOInterface.java new file mode 100644 index 000000000..e01c9422b --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/acid/BondVOInterface.java @@ -0,0 +1,93 @@ +/* + * Copyright 2012-2018 Chronicle Map Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.openhft.chronicle.map.acid; + +import net.openhft.chronicle.values.Array; +import net.openhft.chronicle.values.Group; +import net.openhft.chronicle.values.MaxUtf8Length; + +public interface BondVOInterface { + + @Group(0) + long getEntryLockState(); + + void setEntryLockState(long entryLockState); + + @Group(1) + long getIssueDate(); + + void setIssueDate(long issueDate); /* time in millis */ + + @Group(1) + long getMaturityDate(); + + void setMaturityDate(long maturityDate); /* time in millis */ + + long addAtomicMaturityDate(long toAdd); + + @Group(1) + boolean compareAndSwapCoupon(double expected, double value); + + double getCoupon(); + + void setCoupon(double coupon); + + double addAtomicCoupon(double toAdd); + + @Group(1) + String getSymbol(); + + void setSymbol(@MaxUtf8Length(20) String symbol); + + // OpenHFT Off-Heap array[ ] processing notice ‘At’ suffix + @Group(1) + @Array(length = 7) + void setMarketPxIntraDayHistoryAt(int tradingDayHour, MarketPx mPx); + + /* 7 Hours in the Trading Day: + * index_0 = 9.30am, + * index_1 = 10.30am, + …, + * index_6 = 4.30pm + */ + + MarketPx getMarketPxIntraDayHistoryAt(int tradingDayHour); + + /* nested interface - empowering an Off-Heap hierarchical “TIER of prices” + as array[ ] value */ + interface MarketPx { + double getCallPx(); + + void setCallPx(double px); + + double getParPx(); + + void setParPx(double px); + + double getMaturityPx(); + + void setMaturityPx(double px); + + double getBidPx(); + + void setBidPx(double px); + + double getAskPx(); + + void setAskPx(double px); + } +} diff --git a/src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolation.java b/src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolation.java new file mode 100644 index 000000000..4a8cc66ff --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolation.java @@ -0,0 +1,18 @@ +package net.openhft.chronicle.map.acid; + +import net.openhft.chronicle.map.ChronicleMap; + + + +public interface ChronicleAcidIsolation extends java.sql.Connection{ + + int LOWEST_LATENCY = ChronicleAcidIsolation.TRANSACTION_NONE; + int DIRTY_READ_OPTIMISTIC = ChronicleAcidIsolation.TRANSACTION_READ_UNCOMMITTED; + int DIRTY_READ_INTOLERANT = ChronicleAcidIsolation.TRANSACTION_READ_COMMITTED; + int REPEATABLE_READS_MANDATORY = ChronicleAcidIsolation.TRANSACTION_REPEATABLE_READ; + int PHANTOM_READ_INTOLERANT = ChronicleAcidIsolation.TRANSACTION_SERIALIZABLE; + + + +} + diff --git a/src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolationGovernor.java b/src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolationGovernor.java new file mode 100644 index 000000000..814535f06 --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/acid/ChronicleAcidIsolationGovernor.java @@ -0,0 +1,355 @@ +package net.openhft.chronicle.map.acid; + +//import net.openhft.affinity.AffinitySupport; + +import net.openhft.chronicle.map.ChronicleMap; +import net.openhft.chronicle.map.ChronicleMapBuilder; +import net.openhft.chronicle.map.acid.BondVOInterface; + +import java.io.File; +import java.io.IOException; +import java.math.BigDecimal; +import java.sql.*; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +public class ChronicleAcidIsolationGovernor implements ChronicleAcidIsolation { + private int transactionIsolation; + private ChronicleMap transactionIsolationMap; //to demo in same JVM at first + private ChronicleMap compositeChronicleMap; //hacked in + private String priorCusip; + private Double priorCoupon; + + + public synchronized void put(String cusip, BondVOInterface bond) throws Exception { + this.priorCusip = cusip; + this.priorCoupon = this.getCompositeChronicleMap().get(cusip).getCoupon(); + this.getTransactionIsolationMap().put(Thread.currentThread(), this.getTransactionIsolation()); + bond.setCoupon(priorCoupon + 0.5); + this.getCompositeChronicleMap().put(cusip, bond); + } + + + //here is where the drama happens + public synchronized BondVOInterface get(String cusip) throws InterruptedException { + + BondVOInterface b = null; + if (this.getTransactionIsolationMap().size() > 1) { //other ACID transactions are active + if (this.getTransactionIsolationMap().get(Thread.currentThread()) <= ChronicleAcidIsolation.DIRTY_READ_OPTIMISTIC) { + b = this.compositeChronicleMap.get(cusip); + } else if (this.getTransactionIsolationMap().get(Thread.currentThread()) >= ChronicleAcidIsolation.DIRTY_READ_INTOLERANT) { + this.wait(); + b = this.compositeChronicleMap.get(cusip); + } + } else { + b = this.compositeChronicleMap.get(cusip); + } + + return b; + } + + public ChronicleMap getTransactionIsolationMap() { + return transactionIsolationMap; + } + + public void setTransactionIsolationMap(ChronicleMap transactionIsolationMap) { + this.transactionIsolationMap = transactionIsolationMap; + } + + public ChronicleMap getCompositeChronicleMap() { + return compositeChronicleMap; + } + + public void setCompositeChronicleMap(ChronicleMap compositeChronicleMap) { + this.compositeChronicleMap = compositeChronicleMap; + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + this.transactionIsolation = level; + } + + @Override + public int getTransactionIsolation() throws SQLException { + return this.transactionIsolation; + } + @Override + public synchronized void commit() throws SQLException { + this.getTransactionIsolationMap().remove(Thread.currentThread()); + this.notifyAll(); + + } + + @Override + public synchronized void rollback() throws SQLException { + BondVOInterface priorBond = this.compositeChronicleMap.get(priorCusip); + priorBond.setCoupon(priorCoupon); + this.getCompositeChronicleMap().put(priorCusip,priorBond); + this.getTransactionIsolationMap().remove(Thread.currentThread()); + this.notifyAll(); + } + + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + + } + + @Override + public boolean getAutoCommit() throws SQLException { + return false; + } + + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + + } + + @Override + public void close() throws SQLException { + + } + + + // rest of these java.sql.Connection methods remain unimplemented ... + // pedantics are too + // intense. In the real world, even in Captital Markets 'dirty read' intolerance + // is likely the only isolation level Chronicle would accommodate. + + @Override + public Statement createStatement() throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return null; + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + return null; + } + + @Override + public String nativeSQL(String sql) throws SQLException { + return null; + } + + + @Override + public boolean isClosed() throws SQLException { + return false; + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + return null; + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + + } + + @Override + public boolean isReadOnly() throws SQLException { + return false; + } + + @Override + public void setCatalog(String catalog) throws SQLException { + + } + + @Override + public String getCatalog() throws SQLException { + return null; + } + + + @Override + public SQLWarning getWarnings() throws SQLException { + return null; + } + + @Override + public void clearWarnings() throws SQLException { + + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { + return null; + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { + return null; + } + + @Override + public Map> getTypeMap() throws SQLException { + return null; + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + + } + + @Override + public void setHoldability(int holdability) throws SQLException { + + } + + @Override + public int getHoldability() throws SQLException { + return 0; + } + + @Override + public Savepoint setSavepoint() throws SQLException { + return null; + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + return null; + } + + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + return null; + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + return null; + } + + @Override + public Clob createClob() throws SQLException { + return null; + } + + @Override + public Blob createBlob() throws SQLException { + return null; + } + + @Override + public NClob createNClob() throws SQLException { + return null; + } + + @Override + public SQLXML createSQLXML() throws SQLException { + return null; + } + + @Override + public boolean isValid(int timeout) throws SQLException { + return false; + } + + @Override + public void setClientInfo(String name, String value) throws SQLClientInfoException { + + } + + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + + } + + @Override + public String getClientInfo(String name) throws SQLException { + return null; + } + + @Override + public Properties getClientInfo() throws SQLException { + return null; + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return null; + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return null; + } + + @Override + public void setSchema(String schema) throws SQLException { + + } + + @Override + public String getSchema() throws SQLException { + return null; + } + + @Override + public void abort(Executor executor) throws SQLException { + + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + + } + + @Override + public int getNetworkTimeout() throws SQLException { + return 0; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + +} diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadIntolerant.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadIntolerant.java new file mode 100644 index 000000000..bf77c124a --- /dev/null +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadIntolerant.java @@ -0,0 +1,122 @@ +package net.openhft.chronicle.map.fromdocs.acid; + +import com.sun.org.apache.xpath.internal.operations.Bool; +import net.openhft.affinity.AffinitySupport; +import net.openhft.chronicle.map.ChronicleMap; +import net.openhft.chronicle.map.ChronicleMapBuilder; +import net.openhft.chronicle.map.acid.ChronicleAcidIsolation; +import net.openhft.chronicle.map.acid.ChronicleAcidIsolationGovernor; +import net.openhft.chronicle.map.acid.BondVOInterface; +import net.openhft.chronicle.map.fromdocs.pingpong_latency.PingPongCASLeft; + +import java.io.File; +import java.io.IOException; +import java.sql.SQLException; +import java.util.Arrays; + +import static net.openhft.chronicle.values.Values.newNativeReference; + + +public class DirtyReadIntolerant { + + public static void main(String... ignored) throws IOException, SQLException { + + ChronicleMap operand = + DirtyReadIntolerant.acquireChronicleMapOperand( + "C:\\Users\\buddy\\dev\\shm\\OPERAND_CHRONICLE_MAP" + ); + ChronicleMap operator = + DirtyReadIntolerant.acquireChronicleMapOperator( + "C:\\Users\\buddy\\dev\\shm\\OPERATOR_CHRONICLE_MAP" + ); + ChronicleAcidIsolationGovernor craig = new ChronicleAcidIsolationGovernor(); + craig.setCompositeChronicleMap(operand); + craig.setAutoCommit(Boolean.FALSE); + craig.setTransactionIsolationMap(operator); + + DirtyReadOffender offender = new DirtyReadOffender(); + offender.setCraig(craig); + + DirtyReadVictim victim = new DirtyReadVictim(); + victim.setCraig(craig); + + (new Thread(offender)).start(); + (new Thread(victim)).start(); + + + } + +// + + static ChronicleMap acquireChronicleMapOperand(String operand) + throws IOException { + // ensure thread ids are globally unique. + AffinitySupport.setThreadId(); + return ChronicleMapBuilder.of(String.class, BondVOInterface.class) + .entries(16) + .averageKeySize("123456789".length()) + .createPersistedTo( + new File( + operand + // "C:\\Users\\buddy\\dev\\shm\\OPERAND_CHRONICLE_MAP" + ) + ); + //.create(); + } + + static ChronicleMap acquireChronicleMapOperator(String operator) + throws IOException { + // ensure thread ids are globally unique. + AffinitySupport.setThreadId(); + return ChronicleMapBuilder.of(Thread.class, Integer.class) + .entries(16) + .averageKeySize("123456789".length()) + .createPersistedTo( + new File( + operator + // "C:\\Users\\buddy\\dev\\shm\\OPERATOR_CHRONICLE_MAP" + ) + ); + //.create(); + } + +// static void offendPrice(ChronicleMap chm, double _coupon, +// double _coupon2, boolean setFirst, final String desc) { +// BondVOInterface bond1 = newNativeReference(BondVOInterface.class); +// BondVOInterface bond2 = newNativeReference(BondVOInterface.class); +// BondVOInterface bond3 = newNativeReference(BondVOInterface.class); +// BondVOInterface bond4 = newNativeReference(BondVOInterface.class); +// +// chm.acquireUsing("369604101", bond1); +// chm.acquireUsing("369604102", bond2); +// chm.acquireUsing("369604103", bond3); +// chm.acquireUsing("369604104", bond4); +// System.out.printf( +// "\n\n" + desc + +// ": Timing 1 x off-heap operations on /dev/shm/RDR_DIM_Mock\n" +// ); +// if (setFirst) { +// bond1.setCoupon(_coupon); +// bond2.setCoupon(_coupon); +// bond3.setCoupon(_coupon); +// bond4.setCoupon(_coupon); +// } +// int timeToCallNanoTime = 30; +// int runs = 1000000; +// long[] timings = new long[runs]; +// for (int j = 0; j < 10; j++) { +// for (int i = 0; i < runs; i++) { +// long _start = System.nanoTime(); // +// while (!bond1.compareAndSwapCoupon(_coupon, _coupon2)) ; +// //while (!bond2.compareAndSwapCoupon(_coupon, _coupon2)) ; +// //while (!bond3.compareAndSwapCoupon(_coupon, _coupon2)) ; +// //while (!bond4.compareAndSwapCoupon(_coupon, _coupon2)) ; +// +// timings[i] = (System.nanoTime() - _start - timeToCallNanoTime) / 4; +// } +// Arrays.sort(timings); +// System.out.printf("#%d: compareAndSwapCoupon() 50/90/99%%tile was %,d / %,d / %,d%n", +// j, timings[runs / 2], timings[runs * 9 / 10], timings[runs * 99 / 100]); +// } +// } +} diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadOffender.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadOffender.java new file mode 100644 index 000000000..095893dd4 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadOffender.java @@ -0,0 +1,45 @@ +package net.openhft.chronicle.map.fromdocs.acid; + +import net.openhft.chronicle.map.acid.ChronicleAcidIsolation; +import net.openhft.chronicle.map.acid.ChronicleAcidIsolationGovernor; +import net.openhft.chronicle.map.acid.BondVOInterface; + +import java.sql.SQLException; + +import static net.openhft.chronicle.values.Values.newNativeReference; + +public class DirtyReadOffender implements Runnable { + + ChronicleAcidIsolationGovernor craig; + + public ChronicleAcidIsolationGovernor getCraig() { + return craig; + } + + public void setCraig(ChronicleAcidIsolationGovernor craig) { + this.craig = craig; + } + + + @Override + public void run() { + + try { + BondVOInterface bond = newNativeReference(BondVOInterface.class); + craig.getCompositeChronicleMap().acquireUsing("369604101", bond); + craig.setTransactionIsolation(ChronicleAcidIsolation.LOWEST_LATENCY); + bond.setCoupon(4.55); + craig.put("369604101",bond); + craig.commit(); + } catch (Exception throwables) { + try { + craig.rollback(); + } catch (SQLException e) { + e.printStackTrace(); + } + throwables.printStackTrace(); + } + + } + +} diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadVictim.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadVictim.java new file mode 100644 index 000000000..f5901380b --- /dev/null +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/DirtyReadVictim.java @@ -0,0 +1,46 @@ +package net.openhft.chronicle.map.fromdocs.acid; + + +import net.openhft.chronicle.map.acid.BondVOInterface; +import net.openhft.chronicle.map.acid.ChronicleAcidIsolation; +import net.openhft.chronicle.map.acid.ChronicleAcidIsolationGovernor; + +import java.sql.SQLException; + +import static net.openhft.chronicle.values.Values.newNativeReference; + +public class DirtyReadVictim implements Runnable { + + ChronicleAcidIsolationGovernor craig; + + public ChronicleAcidIsolationGovernor getCraig() { + return craig; + } + + public void setCraig(ChronicleAcidIsolationGovernor craig) { + this.craig = craig; + } + + @Override + public void run() { + try { + BondVOInterface bond = newNativeReference(BondVOInterface.class); + craig.getCompositeChronicleMap().acquireUsing("369604101", bond); + + craig.setTransactionIsolation(ChronicleAcidIsolation.DIRTY_READ_INTOLERANT); //start tx + bond = craig.getCompositeChronicleMap().get("369604101"); + Double coupon = bond.getCoupon(); + craig.commit(); + } catch (Exception throwables) { + try { + craig.rollback(); + } catch (SQLException e) { + e.printStackTrace(); + } + throwables.printStackTrace(); + } + + + } +} + diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java index 4475b0934..af9e1ea48 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java @@ -21,6 +21,7 @@ import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.fromdocs.BondVOInterface; +import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -28,7 +29,7 @@ import static net.openhft.chronicle.values.Values.newNativeReference; /* on an i7-4500 laptop. -PingPongLEFT: Timing 1 x off-heap operations on /dev/chm/RDR_DIM_Mock +PingPongLEFT: Timing 1 x off-heap operations on /dev/shm/RDR_DIM_Mock #0: compareAndSwapCoupon() 50/90/99%tile was 41 / 52 / 132 #1: compareAndSwapCoupon() 50/90/99%tile was 40 / 56 / 119 #2: compareAndSwapCoupon() 50/90/99%tile was 39 / 48 / 54 @@ -45,11 +46,17 @@ public class PingPongCASLeft { public static void main(String... ignored) throws IOException { ChronicleMap chm = PingPongCASLeft.acquireCHM(); - playPingPong(chm, 4, 5, true, "PingPongCASLEFT"); + playPingPong(chm, 4, 5, true, "PingPongCASLeft"); } - static void playPingPong(ChronicleMap chm, double _coupon, - double _coupon2, boolean setFirst, final String desc) { + static void playPingPong( + ChronicleMap chm, + double _coupon, + double _coupon2, + boolean setFirst, + final String desc + ) { + BondVOInterface bond1 = newNativeReference(BondVOInterface.class); BondVOInterface bond2 = newNativeReference(BondVOInterface.class); BondVOInterface bond3 = newNativeReference(BondVOInterface.class); @@ -59,7 +66,7 @@ public class PingPongCASLeft { chm.acquireUsing("369604102", bond2); chm.acquireUsing("369604103", bond3); chm.acquireUsing("369604104", bond4); - System.out.printf("\n\n" + desc + ": Timing 1 x off-heap operations on /dev/chm/RDR_DIM_Mock\n"); + System.out.printf("\n\n" + desc + ": Timing 1 x off-heap operations on /dev/shm/RDR_DIM_Mock\n"); if (setFirst) { bond1.setCoupon(_coupon); bond2.setCoupon(_coupon); @@ -73,9 +80,9 @@ public class PingPongCASLeft { for (int i = 0; i < runs; i++) { long _start = System.nanoTime(); // while (!bond1.compareAndSwapCoupon(_coupon, _coupon2)) ; - while (!bond2.compareAndSwapCoupon(_coupon, _coupon2)) ; - while (!bond3.compareAndSwapCoupon(_coupon, _coupon2)) ; - while (!bond4.compareAndSwapCoupon(_coupon, _coupon2)) ; + //while (!bond2.compareAndSwapCoupon(_coupon, _coupon2)) ; + //while (!bond3.compareAndSwapCoupon(_coupon, _coupon2)) ; + //while (!bond4.compareAndSwapCoupon(_coupon, _coupon2)) ; timings[i] = (System.nanoTime() - _start - timeToCallNanoTime) / 4; } @@ -90,6 +97,8 @@ public class PingPongCASLeft { AffinitySupport.setThreadId(); return ChronicleMapBuilder.of(String.class, BondVOInterface.class) .entries(16) - .averageKeySize("369604101".length()).create(); + .averageKeySize("369604101".length()) + .createPersistedTo(new File("C:\\Users\\buddy\\dev\\shm\\RDR_DIM_MOCK")); + //.create(); } } \ No newline at end of file diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASRight.java b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASRight.java index ef4eaa886..2432f04a6 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASRight.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASRight.java @@ -27,6 +27,6 @@ public class PingPongCASRight { public static void main(String... ignored) throws IOException { ChronicleMap chm = PingPongCASLeft.acquireCHM(); - playPingPong(chm, 5, 4, false, "PingPongCASLEFT"); + playPingPong(chm, 5, 4, false, "PingPongCASRight"); } } \ No newline at end of file