Skip to content

Commit 5815280

Browse files
authored
update default config changing parallel execution to sequential execution (#34)
1 parent 408debe commit 5815280

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following parameters can be configured in the RandomCutForest builder.
6060
| lambda | double | The decay factor (lambda value) used by stream samplers in this forest. | 1e-5 |
6161
| numberOfTrees | int | The number of trees in this forest. | 100 |
6262
| outputAfter | int | The number of points required by stream samplers before results are returned. | 0.25 * sampleSize |
63-
| parallelExecutionEnabled | boolean | If true, then the forest will create an internal threadpool. Forest updates and traversals will be submitted to this threadpool, and individual trees will be updated or traversed in parallel. | true |
63+
| parallelExecutionEnabled | boolean | If true, then the forest will create an internal threadpool. Forest updates and traversals will be submitted to this threadpool, and individual trees will be updated or traversed in parallel. For larger shingle sizes, dimensions, and number of trees, parallelization may improve throughput. We recommend users benchmark against their target use case. | false |
6464
| randomSeed | long | A seed value used to initialize the random number generators in this forest. | |
6565
| sampleSize | int | The sample size used by stream samplers in this forest | 256 |
6666
| storeSequenceIndexesEnabled | boolean | If true, then sequence indexes (ordinals indicating when a point was added to a tree) will be stored in the forest along with poitn values. | false |

core/src/main/java/com/amazon/randomcutforest/RandomCutForest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class RandomCutForest {
9494
/**
9595
* Parallel execution is enabled by default.
9696
*/
97-
public static final boolean DEFAULT_PARALLEL_EXECUTION_ENABLED = true;
97+
public static final boolean DEFAULT_PARALLEL_EXECUTION_ENABLED = false;
9898

9999
public static final boolean DEFAULT_APPROXIMATE_ANOMALY_SCORE_HIGH_IS_CRITICAL = true;
100100

core/src/test/java/com/amazon/randomcutforest/RandomCutForestBuilderTest.java

+22-6
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public void testDefaultForestWithDimensionArgument() {
7373
assertEquals(256 / DEFAULT_OUTPUT_AFTER_FRACTION, f.getOutputAfter());
7474
assertFalse(f.storeSequenceIndexesEnabled());
7575
assertFalse(f.centerOfMassEnabled());
76-
assertTrue(f.parallelExecutionEnabled());
77-
assertEquals(Runtime.getRuntime().availableProcessors() - 1, f.getThreadPoolSize());
76+
assertFalse(f.parallelExecutionEnabled());
77+
assertEquals(0, f.getThreadPoolSize());
7878
}
7979

8080
@Test
@@ -85,8 +85,8 @@ public void testDefaultForestWithDimensionAndRandomSeedArguments() {
8585
assertEquals(256 / DEFAULT_OUTPUT_AFTER_FRACTION, f.getOutputAfter());
8686
assertFalse(f.storeSequenceIndexesEnabled());
8787
assertFalse(f.centerOfMassEnabled());
88-
assertTrue(f.parallelExecutionEnabled());
89-
assertEquals(Runtime.getRuntime().availableProcessors() - 1, f.getThreadPoolSize());
88+
assertFalse(f.parallelExecutionEnabled());
89+
assertEquals(0, f.getThreadPoolSize());
9090
}
9191

9292
@Test
@@ -97,8 +97,24 @@ public void testDefaultForestWithCustomOutputAfterArgument() {
9797
assertEquals(256 / DEFAULT_OUTPUT_AFTER_FRACTION, f.getOutputAfter());
9898
assertFalse(f.storeSequenceIndexesEnabled());
9999
assertFalse(f.centerOfMassEnabled());
100-
assertTrue(f.parallelExecutionEnabled());
101-
assertEquals(Runtime.getRuntime().availableProcessors() - 1, f.getThreadPoolSize());
100+
assertFalse(f.parallelExecutionEnabled());
101+
assertEquals(0, f.getThreadPoolSize());
102+
}
103+
104+
@Test
105+
public void testForestBuilderWithDefaultParallelExecutionThreadPoolSize() {
106+
RandomCutForest forest = RandomCutForest.builder().numberOfTrees(numberOfTrees).sampleSize(sampleSize)
107+
.outputAfter(outputAfter).dimensions(dimensions).lambda(lambda).randomSeed(randomSeed)
108+
.storeSequenceIndexesEnabled(true).centerOfMassEnabled(true).parallelExecutionEnabled(true).build();
109+
assertEquals(numberOfTrees, forest.getNumberOfTrees());
110+
assertEquals(sampleSize, forest.getSampleSize());
111+
assertEquals(outputAfter, forest.getOutputAfter());
112+
assertEquals(dimensions, forest.getDimensions());
113+
assertEquals(lambda, forest.getLambda());
114+
assertTrue(forest.storeSequenceIndexesEnabled());
115+
assertTrue(forest.centerOfMassEnabled());
116+
assertTrue(forest.parallelExecutionEnabled());
117+
assertEquals(Runtime.getRuntime().availableProcessors() - 1, forest.getThreadPoolSize());
102118
}
103119

104120
@Test

serialization-json/src/main/java/com/amazon/randomcutforest/serialize/RandomCutForestAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public class RandomCutForestAdapter implements InstanceCreator<RandomCutForest>
2727

2828
@Override
2929
public RandomCutForest createInstance(Type type) {
30-
return RandomCutForest.defaultForest(1);
30+
return RandomCutForest.builder().dimensions(1).numberOfTrees(1).build();
3131
}
3232
}

0 commit comments

Comments
 (0)