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
=== modified file 'src/main/java/com/persistit/TreeBuilder.java'
--- src/main/java/com/persistit/TreeBuilder.java 2013-01-03 17:13:07 +0000
+++ src/main/java/com/persistit/TreeBuilder.java 2013-01-04 00:17:20 +0000
@@ -162,7 +162,6 @@
162 }162 }
163 };163 };
164164
165
166 private final Comparator<Tree> _defaultTreeComparator = new Comparator<Tree>() {165 private final Comparator<Tree> _defaultTreeComparator = new Comparator<Tree>() {
167 @Override166 @Override
168 public int compare(final Tree a, final Tree b) {167 public int compare(final Tree a, final Tree b) {
@@ -551,7 +550,7 @@
551 for (final Volume volume : _sortVolumes) {550 for (final Volume volume : _sortVolumes) {
552 try {551 try {
553 volume.close();552 volume.close();
554 } catch (PersistitException e) {553 } catch (final PersistitException e) {
555 if (exception == null) {554 if (exception == null) {
556 exception = e;555 exception = e;
557 }556 }
558557
=== modified file 'src/main/java/com/persistit/VolumeStorageT2.java'
--- src/main/java/com/persistit/VolumeStorageT2.java 2012-12-31 01:47:18 +0000
+++ src/main/java/com/persistit/VolumeStorageT2.java 2013-01-04 00:17:20 +0000
@@ -342,7 +342,7 @@
342 }342 }
343343
344 @Override344 @Override
345 long allocNewPage() throws PersistitException {345 synchronized long allocNewPage() throws PersistitException {
346 if (_nextAvailablePage >= _maxPages) {346 if (_nextAvailablePage >= _maxPages) {
347 throw new VolumeFullException(_volume.getName());347 throw new VolumeFullException(_volume.getName());
348 }348 }
349349
=== modified file 'src/test/java/com/persistit/stress/InsertBigLoad.java'
--- src/test/java/com/persistit/stress/InsertBigLoad.java 2012-12-31 20:58:07 +0000
+++ src/test/java/com/persistit/stress/InsertBigLoad.java 2013-01-04 00:17:20 +0000
@@ -18,7 +18,9 @@
18import com.persistit.Configuration;18import com.persistit.Configuration;
19import com.persistit.Persistit;19import com.persistit.Persistit;
20import com.persistit.Transaction.CommitPolicy;20import com.persistit.Transaction.CommitPolicy;
21import com.persistit.TreeBuilder;
21import com.persistit.stress.unit.BigLoad;22import com.persistit.stress.unit.BigLoad;
23import com.persistit.stress.unit.BigLoad.BigLoadTreeBuilder;
2224
23public class InsertBigLoad extends AbstractSuite {25public class InsertBigLoad extends AbstractSuite {
2426
@@ -39,14 +41,21 @@
3941
40 deleteFiles(substitute("$datapath$/persistit*"));42 deleteFiles(substitute("$datapath$/persistit*"));
4143
42 add(new BigLoad("records=10000000"));
43
44 final Configuration config = makeConfiguration(16384, "50000", CommitPolicy.SOFT);44 final Configuration config = makeConfiguration(16384, "50000", CommitPolicy.SOFT);
45 config.setTmpVolMaxSize(100000000000l);45 config.setTmpVolMaxSize(10000000000l);
46 final Persistit persistit = new Persistit(config);46 final Persistit persistit = new Persistit(config);
47 final TreeBuilder tb = new BigLoadTreeBuilder(persistit);
48
49 add(new BigLoad(tb, "records=10000000"));
50 add(new BigLoad(tb, "records=10000000"));
51 add(new BigLoad(tb, "records=10000000"));
52 add(new BigLoad(tb, "records=10000000"));
53 add(new BigLoad(tb, "records=10000000"));
4754
48 try {55 try {
49 execute(persistit);56 execute(persistit);
57 tb.merge();
58
50 } finally {59 } finally {
51 persistit.close();60 persistit.close();
52 }61 }
5362
=== modified file 'src/test/java/com/persistit/stress/unit/BigLoad.java'
--- src/test/java/com/persistit/stress/unit/BigLoad.java 2012-12-31 21:03:59 +0000
+++ src/test/java/com/persistit/stress/unit/BigLoad.java 2013-01-04 00:17:20 +0000
@@ -47,33 +47,19 @@
47public class BigLoad extends AbstractStressTest {47public class BigLoad extends AbstractStressTest {
4848
49 private static final Random RANDOM = new Random();49 private static final Random RANDOM = new Random();
50 private final TreeBuilder tb;
5051
51 private int totalRecords;52 private int totalRecords;
5253
53 public BigLoad(final int totalRecords, final int buckets) {54 public BigLoad(final TreeBuilder tb, final int totalRecords, final int buckets) {
54 super("");55 super("");
55 this.totalRecords = totalRecords;56 this.totalRecords = totalRecords;
57 this.tb = tb;
56 }58 }
5759
58 public void load(final Persistit db) throws Exception {60 public long load(final Persistit db) throws Exception {
59 final long startLoadTime = System.nanoTime();61 final long startLoadTime = System.nanoTime();
60 final TreeBuilder tb = new TreeBuilder(db) {62
61 @Override
62 protected void reportSorted(final long count) {
63 System.out.printf("Sorted %,15d records\n", count);
64 }
65
66 @Override
67 protected void reportMerged(final long count) {
68 System.out.printf("Merged %,15d records\n", count);
69 }
70
71 @Override
72 protected boolean duplicateKeyDetected(final Tree tree, final Key key, final Value v1, final Value v2) {
73 System.out.println("Duplicate key detected: " + key);
74 return true;
75 }
76 };
77 final Exchange resultExchange = db.getExchange("persistit", "sorted", true);63 final Exchange resultExchange = db.getExchange("persistit", "sorted", true);
78 System.out.printf("Loading %,d records\n", totalRecords);64 System.out.printf("Loading %,d records\n", totalRecords);
7965
@@ -84,14 +70,26 @@
84 final long endLoadTime = System.nanoTime();70 final long endLoadTime = System.nanoTime();
85 System.out.printf("Loaded %,d records into %,d buckets in %,dms\n", totalRecords, tb.getSortVolumeCount(),71 System.out.printf("Loaded %,d records into %,d buckets in %,dms\n", totalRecords, tb.getSortVolumeCount(),
86 (endLoadTime - startLoadTime) / Util.NS_PER_MS);72 (endLoadTime - startLoadTime) / Util.NS_PER_MS);
73 return endLoadTime - startLoadTime;
74 }
75
76 public long merge(final Persistit db) throws Exception {
77 final long startMergeTime = System.nanoTime();
8778
88 System.out.printf("Merging %,d records into main database\n", totalRecords);79 System.out.printf("Merging %,d records into main database\n", totalRecords);
8980
90 tb.merge();81 tb.merge();
91 final long endMergeTime = System.nanoTime();82 final long endMergeTime = System.nanoTime();
92 System.out.printf("Merged %,d records in %,dms\n", totalRecords, (endMergeTime - endLoadTime) / Util.NS_PER_MS);83 System.out.printf("Merged %,d records in %,dms\n", totalRecords, (endMergeTime - startMergeTime)
9384 / Util.NS_PER_MS);
85
86 return endMergeTime - startMergeTime;
87 }
88
89 public long count(final Persistit db) throws Exception {
90 final long startCountTime = System.nanoTime();
94 System.out.printf("Counting keys in main database (100M keys per dot) ");91 System.out.printf("Counting keys in main database (100M keys per dot) ");
92 final Exchange resultExchange = db.getExchange("persistit", "sorted", false);
95 resultExchange.clear().append(Key.BEFORE);93 resultExchange.clear().append(Key.BEFORE);
96 long count = 0;94 long count = 0;
97 while (resultExchange.next()) {95 while (resultExchange.next()) {
@@ -102,10 +100,9 @@
102 }100 }
103 }101 }
104 final long endCountTime = System.nanoTime();102 final long endCountTime = System.nanoTime();
105 System.out.printf("\nCounted %,d keys in the main database in %,dms\n", count, (endCountTime - endMergeTime)103 System.out.printf("\nCounted %,d keys in the main database in %,dms\n", count, (endCountTime - startCountTime)
106 / Util.NS_PER_MS);104 / Util.NS_PER_MS);
107 System.out.printf("Total time to load, merge and count %,d records is %,dms", totalRecords,105 return endCountTime - startCountTime;
108 (endCountTime - startLoadTime) / Util.NS_PER_MS);
109 }106 }
110107
111 final StringBuilder sb = new StringBuilder(108 final StringBuilder sb = new StringBuilder(
@@ -136,7 +133,6 @@
136 public static void main(final String[] args) throws Exception {133 public static void main(final String[] args) throws Exception {
137 final int records = args.length > 0 ? Integer.parseInt(args[0]) : 1000000;134 final int records = args.length > 0 ? Integer.parseInt(args[0]) : 1000000;
138 final int buckets = args.length > 1 ? Integer.parseInt(args[1]) : 100;135 final int buckets = args.length > 1 ? Integer.parseInt(args[1]) : 100;
139 final BigLoad bl = new BigLoad(records, buckets);
140 final Persistit db = new Persistit();136 final Persistit db = new Persistit();
141 if (args.length > 2) {137 if (args.length > 2) {
142 db.setPropertiesFromFile(args[2]);138 db.setPropertiesFromFile(args[2]);
@@ -144,13 +140,39 @@
144 } else {140 } else {
145 db.initialize();141 db.initialize();
146 }142 }
143 final BigLoad bl = new BigLoad(new BigLoadTreeBuilder(db), records, buckets);
147 try {144 try {
148 bl.load(db);145 bl.load(db);
146 bl.merge(db);
147 bl.clone();
149 } finally {148 } finally {
150 db.close();149 db.close();
151 }150 }
152 }151 }
153152
153 public static class BigLoadTreeBuilder extends TreeBuilder {
154
155 public BigLoadTreeBuilder(final Persistit db) {
156 super(db);
157 }
158
159 @Override
160 protected void reportSorted(final long count) {
161 System.out.printf("Sorted %,15d records\n", count);
162 }
163
164 @Override
165 protected void reportMerged(final long count) {
166 System.out.printf("Merged %,15d records\n", count);
167 }
168
169 @Override
170 protected boolean duplicateKeyDetected(final Tree tree, final Key key, final Value v1, final Value v2) {
171 System.out.println("Duplicate key detected: " + key);
172 return true;
173 }
174 }
175
154 /*176 /*
155 * ----------------------------------------------------------------------177 * ----------------------------------------------------------------------
156 * 178 *
@@ -159,8 +181,9 @@
159 * ----------------------------------------------------------------------181 * ----------------------------------------------------------------------
160 */182 */
161183
162 public BigLoad(final String argsString) {184 public BigLoad(final TreeBuilder tb, final String argsString) {
163 super(argsString);185 super(argsString);
186 this.tb = tb;
164 }187 }
165188
166 private final static String[] ARGS_TEMPLATE = { "records|int:1000000:1:1000000000|Total records to create",189 private final static String[] ARGS_TEMPLATE = { "records|int:1000000:1:1000000000|Total records to create",

Subscribers

People subscribed via source and target branches