Merge lp:~pbeaman/akiban-persistit/parameterize-tests into lp:akiban-persistit

Proposed by Peter Beaman
Status: Merged
Approved by: Nathan Williams
Approved revision: 384
Merged at revision: 384
Proposed branch: lp:~pbeaman/akiban-persistit/parameterize-tests
Merge into: lp:akiban-persistit
Diff against target: 250 lines (+99/-13)
4 files modified
src/main/java/com/persistit/CheckpointManager.java (+3/-8)
src/main/java/com/persistit/Configuration.java (+40/-3)
src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java (+6/-0)
src/test/java/com/persistit/stress/AbstractSuite.java (+50/-2)
To merge this branch: bzr merge lp:~pbeaman/akiban-persistit/parameterize-tests
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+131075@code.launchpad.net

Description of the change

This branch makes it easier to global modify configuration parameters for stress tests so that we can easily scale the the buffer pool size, checkpoint interval and commit policy for different hardware environments. Adds a Configuration property to set the default checkpoint interval. Adds logic to AbstractSuite to scale buffer pool configuration up or down, set checkpoint interval and default commit policy.

This branch is in preparation for a Matrix Jenkins test configuration. In the future we may want to do something even more general, but for now these settings are sufficient.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

As described.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/persistit/CheckpointManager.java'
2--- src/main/java/com/persistit/CheckpointManager.java 2012-10-11 14:38:30 +0000
3+++ src/main/java/com/persistit/CheckpointManager.java 2012-10-23 19:13:24 +0000
4@@ -93,17 +93,11 @@
5 /**
6 * Default interval in nanoseconds between checkpoints - two minutes.
7 */
8- private final static long DEFAULT_CHECKPOINT_INTERVAL = 120;
9-
10- private final static long MINIMUM_CHECKPOINT_INTERVAL = 10;
11-
12- private final static long MAXIMUM_CHECKPOINT_INTERVAL = 1800;
13-
14 private final static Checkpoint UNAVALABLE_CHECKPOINT = new Checkpoint(0, 0);
15
16 private final SessionId _checkpointTxnSessionId = new SessionId();
17
18- private volatile long _checkpointIntervalNanos = DEFAULT_CHECKPOINT_INTERVAL * NS_PER_S;
19+ private volatile long _checkpointIntervalNanos;
20
21 private volatile long _lastCheckpointNanos = Long.MAX_VALUE;
22
23@@ -125,6 +119,7 @@
24
25 public void start() {
26 _closed.set(false);
27+ _checkpointIntervalNanos = _persistit.getConfiguration().getCheckpointInterval() * NS_PER_S;
28 start("CHECKPOINT_WRITER", FLUSH_CHECKPOINT_INTERVAL);
29 }
30
31@@ -161,7 +156,7 @@
32
33 @Override
34 public void setCheckpointInterval(final long interval) {
35- Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL, MAXIMUM_CHECKPOINT_INTERVAL);
36+ Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL_S, MAXIMUM_CHECKPOINT_INTERVAL_S);
37 _checkpointIntervalNanos = interval * NS_PER_S;
38 }
39
40
41=== modified file 'src/main/java/com/persistit/Configuration.java'
42--- src/main/java/com/persistit/Configuration.java 2012-10-15 21:22:32 +0000
43+++ src/main/java/com/persistit/Configuration.java 2012-10-23 19:13:24 +0000
44@@ -15,6 +15,10 @@
45
46 package com.persistit;
47
48+import static com.persistit.mxbeans.CheckpointManagerMXBean.DEFAULT_CHECKPOINT_INTERVAL_S;
49+import static com.persistit.mxbeans.CheckpointManagerMXBean.MAXIMUM_CHECKPOINT_INTERVAL_S;
50+import static com.persistit.mxbeans.CheckpointManagerMXBean.MINIMUM_CHECKPOINT_INTERVAL_S;
51+
52 import java.io.File;
53 import java.io.FileInputStream;
54 import java.io.FileNotFoundException;
55@@ -39,6 +43,7 @@
56 import com.persistit.exception.PersistitIOException;
57 import com.persistit.exception.PropertiesNotFoundException;
58 import com.persistit.logging.DefaultPersistitLogger;
59+import com.persistit.mxbeans.CheckpointManagerMXBean;
60 import com.persistit.policy.JoinPolicy;
61 import com.persistit.policy.SplitPolicy;
62 import com.persistit.util.Util;
63@@ -168,6 +173,11 @@
64 public final static String SYSTEM_VOLUME_PROPERTY_NAME = "sysvolume";
65
66 /**
67+ * Property name for checkpoint interval in seconds
68+ */
69+ public final static String CHECKPOINT_INTERVAL_PROPERTY_NAME = "checkpointinterval";
70+
71+ /**
72 * Property name for specifying default temporary volume page size
73 */
74 public final static String TEMPORARY_VOLUME_PAGE_SIZE_PROPERTY_NAME = "tmpvolpagesize";
75@@ -628,6 +638,7 @@
76 private final List<VolumeSpecification> volumeSpecifications = new ArrayList<VolumeSpecification>();
77 private String journalPath = DEFAULT_JOURNAL_PATH;
78 private long journalSize = JournalManager.DEFAULT_BLOCK_SIZE;
79+ private long checkpointInterval = DEFAULT_CHECKPOINT_INTERVAL_S;
80 private String sysVolume = DEFAULT_SYSTEM_VOLUME_NAME;
81 private CommitPolicy commitPolicy = DEFAULT_TRANSACTION_COMMIT_POLICY;
82 private JoinPolicy joinPolicy = DEFAULT_JOIN_POLICY;
83@@ -1045,7 +1056,7 @@
84 * @throws IllegalArgumentException
85 * if the supplied String is not a valid integer representation.
86 */
87- static long parseLongProperty(final String propName, final String str) {
88+ public static long parseLongProperty(final String propName, final String str) {
89 if (str != null) {
90 try {
91 long multiplier = 1;
92@@ -1097,7 +1108,7 @@
93 * if the supplied String is not a valid floating point
94 * representation, or is outside the supplied bounds.
95 */
96- static float parseFloatProperty(final String propName, final String str) {
97+ public static float parseFloatProperty(final String propName, final String str) {
98 if (str != null) {
99 try {
100 return Float.parseFloat(str);
101@@ -1117,7 +1128,7 @@
102 * @param str
103 * @return the boolean value
104 */
105- static boolean parseBooleanValue(final String propName, final String str) {
106+ public static boolean parseBooleanValue(final String propName, final String str) {
107 if ("true".equalsIgnoreCase(str))
108 return true;
109 if ("false".equalsIgnoreCase(str))
110@@ -1290,6 +1301,32 @@
111 }
112
113 /**
114+ * Return the value defined by {@link #setCheckpointInterval(long)}
115+ *
116+ * @return the checkpoint interval, in seconds
117+ */
118+ public long getCheckpointInterval() {
119+ return checkpointInterval;
120+ }
121+
122+ /**
123+ * <p>
124+ * Set the checkpoint interval, in seconds. This setting controls the
125+ * elapsed time between attempts to write a checkpoint to the journal. A
126+ * longer interval allows more updates to accumulate in buffers before they
127+ * are required to be written to disk, but also potentially causes recovery
128+ * from an abrupt termination (crash) to take more time.
129+ * </p>
130+ * Default size is
131+ * {@value CheckpointManagerMXBean#DEFAULT_CHECKPOINT_INTERVAL_S} <br/>
132+ * Property name is {@value #CHECKPOINT_INTERVAL_PROPERTY_NAME}
133+ */
134+ public void setCheckpointInterval(final long checkpointInterval) {
135+ this.checkpointInterval = Util.rangeCheck(checkpointInterval, MINIMUM_CHECKPOINT_INTERVAL_S,
136+ MAXIMUM_CHECKPOINT_INTERVAL_S);
137+ }
138+
139+ /**
140 * Return the value defined by {@link #setSysVolume}
141 *
142 * @return the system volume name
143
144=== modified file 'src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java'
145--- src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java 2012-08-02 04:45:28 +0000
146+++ src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java 2012-10-23 19:13:24 +0000
147@@ -24,6 +24,12 @@
148 @MXBean
149 public interface CheckpointManagerMXBean {
150
151+ public final static long DEFAULT_CHECKPOINT_INTERVAL_S = 120;
152+
153+ public final static long MINIMUM_CHECKPOINT_INTERVAL_S = 10;
154+
155+ public final static long MAXIMUM_CHECKPOINT_INTERVAL_S = 3600;
156+
157 public final static String MXBEAN_NAME = "com.persistit:type=Persistit,class=CheckpointManager";
158
159 @Description("Checkpoint most recently proposed")
160
161=== modified file 'src/test/java/com/persistit/stress/AbstractSuite.java'
162--- src/test/java/com/persistit/stress/AbstractSuite.java 2012-10-04 20:40:40 +0000
163+++ src/test/java/com/persistit/stress/AbstractSuite.java 2012-10-23 19:13:24 +0000
164@@ -42,7 +42,9 @@
165
166 private final static String[] ARGS_TEMPLATE = { "duration|int::10|Maximum duration in seconds",
167 "datapath|String:/tmp/persistit_test_data|Data path",
168- "progress|int:60:1:|Progress message interval in seconds", "_flag|S|Save on failure", };
169+ "progress|int:60:1:|Progress message interval in seconds", "_flag|S|Save on failure",
170+ "checkpointinterval|int:120:10:3600|Checkpoint interval in seconds",
171+ "commitpolicy|String:|Default commit policy", "memoryadjustment|String:|Memory adjustment" };
172
173 protected final static long PROGRESS_LOG_INTERVAL = 600000;
174
175@@ -56,6 +58,9 @@
176 final private String _dataPath;
177 final private long _progressLogInterval;
178 final private boolean _saveOnFailure;
179+ private final int _checkpointInterval;
180+ private final String _commitPolicyOverride;
181+ private final String _memoryAdjustment;
182
183 private long _duration;
184 private boolean _untilStopped;
185@@ -76,6 +81,9 @@
186 _progressLogInterval = ap.getLongValue("progress");
187 _untilStopped = ap.isSpecified("duration");
188 _saveOnFailure = ap.isFlag('S');
189+ _checkpointInterval = ap.isSpecified("checkpointinterval") ? ap.getIntValue("checkpointinterval") : 0;
190+ _commitPolicyOverride = ap.getStringValue("commitpolicy");
191+ _memoryAdjustment = ap.getStringValue("memoryadjustment");
192 }
193
194 public String getName() {
195@@ -292,7 +300,7 @@
196
197 protected Configuration makeConfiguration(final int pageSize, final String mem, final CommitPolicy policy) {
198 final Configuration c = new Configuration();
199- c.setCommitPolicy(policy);
200+ c.setCommitPolicy(overrideCommitPolicy(policy, _commitPolicyOverride));
201 c.setJmxEnabled(true);
202 c.setJournalPath(substitute("$datapath$/persistit_journal"));
203 c.setLogFile(substitute("$datapath$/persistit_$timestamp$.log"));
204@@ -306,6 +314,46 @@
205 c.getVolumeList().add(
206 new VolumeSpecification(substitute("$datapath$/persistit,create,pageSize:" + pageSize
207 + ",initialSize:100M,extensionSize:100M,maximumSize:500G")));
208+ if (_checkpointInterval > 0) {
209+ c.setCheckpointInterval(_checkpointInterval);
210+ }
211+ adjustMemory(bpc);
212 return c;
213 }
214+
215+ private CommitPolicy overrideCommitPolicy(final CommitPolicy policy, final String override) {
216+ return override != null && !override.isEmpty() ? CommitPolicy.valueOf(override) : policy;
217+ }
218+
219+ private void adjustMemory(final BufferPoolConfiguration bpc) {
220+ final int minc = bpc.getMinimumCount();
221+ final int maxc = bpc.getMaximumCount();
222+ final long mins = bpc.getMinimumMemory();
223+ final long maxs = bpc.getMaximumMemory();
224+ if (_memoryAdjustment == null || _memoryAdjustment.isEmpty()) {
225+ return;
226+ }
227+ if (_memoryAdjustment.startsWith("x")) {
228+ final float fraction = Float.parseFloat(_memoryAdjustment.substring(1));
229+ if (minc > 0 && maxc < Integer.MAX_VALUE) {
230+ bpc.setMinimumCount((int) (minc * fraction));
231+ bpc.setMaximumCount((int) (maxc * fraction));
232+ } else {
233+ if (mins > 0 && maxs < Long.MAX_VALUE) {
234+ bpc.setMinimumMemory((long) (mins * fraction));
235+ bpc.setMaximumMemory((long) (maxs * fraction));
236+ }
237+ }
238+ } else if (_memoryAdjustment.startsWith("c")) {
239+ final int count = Integer.parseInt(_memoryAdjustment.substring(1));
240+ bpc.setMinimumCount(count);
241+ bpc.setMaximumCount(count);
242+ } else {
243+ final long size = Configuration.parseLongProperty("MemoryAdjustment", _memoryAdjustment);
244+ bpc.setMinimumCount(0);
245+ bpc.setMaximumCount(Integer.MAX_VALUE);
246+ bpc.setMinimumMemory(0);
247+ bpc.setMaximumMemory(size);
248+ }
249+ }
250 }

Subscribers

People subscribed via source and target branches