Merge lp:~pbeaman/akiban-persistit/tree-builder3 into lp:akiban-persistit

Proposed by Peter Beaman
Status: Merged
Approved by: Nathan Williams
Approved revision: 418
Merged at revision: 409
Proposed branch: lp:~pbeaman/akiban-persistit/tree-builder3
Merge into: lp:akiban-persistit
Diff against target: 216 lines (+63/-32)
4 files modified
src/main/java/com/persistit/TreeBuilder.java (+1/-2)
src/main/java/com/persistit/VolumeStorageT2.java (+1/-1)
src/test/java/com/persistit/stress/InsertBigLoad.java (+12/-3)
src/test/java/com/persistit/stress/unit/BigLoad.java (+49/-26)
To merge this branch: bzr merge lp:~pbeaman/akiban-persistit/tree-builder3
Reviewer Review Type Date Requested Status
Akiban Build User Needs Fixing
Nathan Williams Approve
Review via email: mp+141837@code.launchpad.net

Description of the change

More small tweaks to support multi-threaded use of a TreeBuilder. This branch makes VolumeStorageT2#allocNewPage synchronized, which is necessary for concurrent use of a temporary volume.

In addition, the InsertBigLoad stress test has been modified to run five current sort threads, loading a total of 50M random keys in about three minutes.

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

As described.

review: Approve
Revision history for this message
Akiban Build User (build-akiban) wrote :

There were 2 failures during build/test:

* job system-tests-mtr failed at build number 3074: http://172.16.20.104:8080/job/system-tests-mtr/3074/

* view must-pass failed: system-tests-mtr is red

review: Needs Fixing
Revision history for this message
Nathan Williams (nwilliams) wrote :

Unrelated.

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/TreeBuilder.java'
2--- src/main/java/com/persistit/TreeBuilder.java 2013-01-03 17:13:07 +0000
3+++ src/main/java/com/persistit/TreeBuilder.java 2013-01-04 00:17:20 +0000
4@@ -162,7 +162,6 @@
5 }
6 };
7
8-
9 private final Comparator<Tree> _defaultTreeComparator = new Comparator<Tree>() {
10 @Override
11 public int compare(final Tree a, final Tree b) {
12@@ -551,7 +550,7 @@
13 for (final Volume volume : _sortVolumes) {
14 try {
15 volume.close();
16- } catch (PersistitException e) {
17+ } catch (final PersistitException e) {
18 if (exception == null) {
19 exception = e;
20 }
21
22=== modified file 'src/main/java/com/persistit/VolumeStorageT2.java'
23--- src/main/java/com/persistit/VolumeStorageT2.java 2012-12-31 01:47:18 +0000
24+++ src/main/java/com/persistit/VolumeStorageT2.java 2013-01-04 00:17:20 +0000
25@@ -342,7 +342,7 @@
26 }
27
28 @Override
29- long allocNewPage() throws PersistitException {
30+ synchronized long allocNewPage() throws PersistitException {
31 if (_nextAvailablePage >= _maxPages) {
32 throw new VolumeFullException(_volume.getName());
33 }
34
35=== modified file 'src/test/java/com/persistit/stress/InsertBigLoad.java'
36--- src/test/java/com/persistit/stress/InsertBigLoad.java 2012-12-31 20:58:07 +0000
37+++ src/test/java/com/persistit/stress/InsertBigLoad.java 2013-01-04 00:17:20 +0000
38@@ -18,7 +18,9 @@
39 import com.persistit.Configuration;
40 import com.persistit.Persistit;
41 import com.persistit.Transaction.CommitPolicy;
42+import com.persistit.TreeBuilder;
43 import com.persistit.stress.unit.BigLoad;
44+import com.persistit.stress.unit.BigLoad.BigLoadTreeBuilder;
45
46 public class InsertBigLoad extends AbstractSuite {
47
48@@ -39,14 +41,21 @@
49
50 deleteFiles(substitute("$datapath$/persistit*"));
51
52- add(new BigLoad("records=10000000"));
53-
54 final Configuration config = makeConfiguration(16384, "50000", CommitPolicy.SOFT);
55- config.setTmpVolMaxSize(100000000000l);
56+ config.setTmpVolMaxSize(10000000000l);
57 final Persistit persistit = new Persistit(config);
58+ final TreeBuilder tb = new BigLoadTreeBuilder(persistit);
59+
60+ add(new BigLoad(tb, "records=10000000"));
61+ add(new BigLoad(tb, "records=10000000"));
62+ add(new BigLoad(tb, "records=10000000"));
63+ add(new BigLoad(tb, "records=10000000"));
64+ add(new BigLoad(tb, "records=10000000"));
65
66 try {
67 execute(persistit);
68+ tb.merge();
69+
70 } finally {
71 persistit.close();
72 }
73
74=== modified file 'src/test/java/com/persistit/stress/unit/BigLoad.java'
75--- src/test/java/com/persistit/stress/unit/BigLoad.java 2012-12-31 21:03:59 +0000
76+++ src/test/java/com/persistit/stress/unit/BigLoad.java 2013-01-04 00:17:20 +0000
77@@ -47,33 +47,19 @@
78 public class BigLoad extends AbstractStressTest {
79
80 private static final Random RANDOM = new Random();
81+ private final TreeBuilder tb;
82
83 private int totalRecords;
84
85- public BigLoad(final int totalRecords, final int buckets) {
86+ public BigLoad(final TreeBuilder tb, final int totalRecords, final int buckets) {
87 super("");
88 this.totalRecords = totalRecords;
89+ this.tb = tb;
90 }
91
92- public void load(final Persistit db) throws Exception {
93+ public long load(final Persistit db) throws Exception {
94 final long startLoadTime = System.nanoTime();
95- final TreeBuilder tb = new TreeBuilder(db) {
96- @Override
97- protected void reportSorted(final long count) {
98- System.out.printf("Sorted %,15d records\n", count);
99- }
100-
101- @Override
102- protected void reportMerged(final long count) {
103- System.out.printf("Merged %,15d records\n", count);
104- }
105-
106- @Override
107- protected boolean duplicateKeyDetected(final Tree tree, final Key key, final Value v1, final Value v2) {
108- System.out.println("Duplicate key detected: " + key);
109- return true;
110- }
111- };
112+
113 final Exchange resultExchange = db.getExchange("persistit", "sorted", true);
114 System.out.printf("Loading %,d records\n", totalRecords);
115
116@@ -84,14 +70,26 @@
117 final long endLoadTime = System.nanoTime();
118 System.out.printf("Loaded %,d records into %,d buckets in %,dms\n", totalRecords, tb.getSortVolumeCount(),
119 (endLoadTime - startLoadTime) / Util.NS_PER_MS);
120+ return endLoadTime - startLoadTime;
121+ }
122+
123+ public long merge(final Persistit db) throws Exception {
124+ final long startMergeTime = System.nanoTime();
125
126 System.out.printf("Merging %,d records into main database\n", totalRecords);
127
128 tb.merge();
129 final long endMergeTime = System.nanoTime();
130- System.out.printf("Merged %,d records in %,dms\n", totalRecords, (endMergeTime - endLoadTime) / Util.NS_PER_MS);
131-
132+ System.out.printf("Merged %,d records in %,dms\n", totalRecords, (endMergeTime - startMergeTime)
133+ / Util.NS_PER_MS);
134+
135+ return endMergeTime - startMergeTime;
136+ }
137+
138+ public long count(final Persistit db) throws Exception {
139+ final long startCountTime = System.nanoTime();
140 System.out.printf("Counting keys in main database (100M keys per dot) ");
141+ final Exchange resultExchange = db.getExchange("persistit", "sorted", false);
142 resultExchange.clear().append(Key.BEFORE);
143 long count = 0;
144 while (resultExchange.next()) {
145@@ -102,10 +100,9 @@
146 }
147 }
148 final long endCountTime = System.nanoTime();
149- System.out.printf("\nCounted %,d keys in the main database in %,dms\n", count, (endCountTime - endMergeTime)
150+ System.out.printf("\nCounted %,d keys in the main database in %,dms\n", count, (endCountTime - startCountTime)
151 / Util.NS_PER_MS);
152- System.out.printf("Total time to load, merge and count %,d records is %,dms", totalRecords,
153- (endCountTime - startLoadTime) / Util.NS_PER_MS);
154+ return endCountTime - startCountTime;
155 }
156
157 final StringBuilder sb = new StringBuilder(
158@@ -136,7 +133,6 @@
159 public static void main(final String[] args) throws Exception {
160 final int records = args.length > 0 ? Integer.parseInt(args[0]) : 1000000;
161 final int buckets = args.length > 1 ? Integer.parseInt(args[1]) : 100;
162- final BigLoad bl = new BigLoad(records, buckets);
163 final Persistit db = new Persistit();
164 if (args.length > 2) {
165 db.setPropertiesFromFile(args[2]);
166@@ -144,13 +140,39 @@
167 } else {
168 db.initialize();
169 }
170+ final BigLoad bl = new BigLoad(new BigLoadTreeBuilder(db), records, buckets);
171 try {
172 bl.load(db);
173+ bl.merge(db);
174+ bl.clone();
175 } finally {
176 db.close();
177 }
178 }
179
180+ public static class BigLoadTreeBuilder extends TreeBuilder {
181+
182+ public BigLoadTreeBuilder(final Persistit db) {
183+ super(db);
184+ }
185+
186+ @Override
187+ protected void reportSorted(final long count) {
188+ System.out.printf("Sorted %,15d records\n", count);
189+ }
190+
191+ @Override
192+ protected void reportMerged(final long count) {
193+ System.out.printf("Merged %,15d records\n", count);
194+ }
195+
196+ @Override
197+ protected boolean duplicateKeyDetected(final Tree tree, final Key key, final Value v1, final Value v2) {
198+ System.out.println("Duplicate key detected: " + key);
199+ return true;
200+ }
201+ }
202+
203 /*
204 * ----------------------------------------------------------------------
205 *
206@@ -159,8 +181,9 @@
207 * ----------------------------------------------------------------------
208 */
209
210- public BigLoad(final String argsString) {
211+ public BigLoad(final TreeBuilder tb, final String argsString) {
212 super(argsString);
213+ this.tb = tb;
214 }
215
216 private final static String[] ARGS_TEMPLATE = { "records|int:1000000:1:1000000000|Total records to create",

Subscribers

People subscribed via source and target branches