You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2015/07/14 11:35:56 UTC
[05/16] incubator-brooklyn git commit: Limit number of threads
executed in parallel
Limit number of threads executed in parallel
On a single-CPU machines threads will build up in the queue which leads to OutOfMemoryException (can't allocate enough memory for the stacks). Also a problem on 32 bit VMs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d2d90c27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d2d90c27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d2d90c27
Branch: refs/heads/master
Commit: d2d90c273d74f98ed004c54aa82907c468feb86d
Parents: ea1d6cb
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jun 10 17:21:15 2015 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Tue Jul 7 17:29:16 2015 +0300
----------------------------------------------------------------------
.../test/java/brooklyn/entity/basic/AttributeMapTest.java | 9 +++++----
.../util/task/BasicTaskExecutionPerformanceTest.java | 4 +++-
2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2d90c27/core/src/test/java/brooklyn/entity/basic/AttributeMapTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/AttributeMapTest.java b/core/src/test/java/brooklyn/entity/basic/AttributeMapTest.java
index 3224041..bdbd25e 100644
--- a/core/src/test/java/brooklyn/entity/basic/AttributeMapTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/AttributeMapTest.java
@@ -51,6 +51,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
public class AttributeMapTest {
+ final int NUM_TASKS = Math.min(500 * Runtime.getRuntime().availableProcessors(), 1000);
Application app;
TestEntityImpl entity;
@@ -77,7 +78,7 @@ public class AttributeMapTest {
public void testConcurrentUpdatesDoNotCauseConcurrentModificationException() throws Exception {
List<Future<?>> futures = Lists.newArrayList();
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < NUM_TASKS; i++) {
final AttributeSensor<String> nextSensor = Sensors.newStringSensor("attributeMapTest.exampleSensor"+i, "");
Future<?> future = executor.submit(newUpdateMapRunnable(map, nextSensor, "a"));
futures.add(future);
@@ -92,7 +93,7 @@ public class AttributeMapTest {
public void testConcurrentUpdatesAndGetsDoNotCauseConcurrentModificationException() throws Exception {
List<Future<?>> futures = Lists.newArrayList();
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < NUM_TASKS; i++) {
final AttributeSensor<String> nextSensor = Sensors.newStringSensor("attributeMapTest.exampleSensor"+i, "");
Future<?> future = executor.submit(newUpdateMapRunnable(map, nextSensor, "a"));
Future<?> future2 = executor.submit(newGetAttributeCallable(map, nextSensor));
@@ -171,7 +172,7 @@ public class AttributeMapTest {
List<Future<?>> futures = Lists.newArrayList();
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < NUM_TASKS; i++) {
Future<?> future = executor.submit(newModifyAttributeCallable(map, sensor, modifier));
futures.add(future);
}
@@ -180,7 +181,7 @@ public class AttributeMapTest {
future.get();
}
- assertEquals(map.getValue(sensor), Integer.valueOf(1000));
+ assertEquals(map.getValue(sensor), Integer.valueOf(NUM_TASKS));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2d90c27/core/src/test/java/brooklyn/util/task/BasicTaskExecutionPerformanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/task/BasicTaskExecutionPerformanceTest.java b/core/src/test/java/brooklyn/util/task/BasicTaskExecutionPerformanceTest.java
index 2788a4c..7fd51dd 100644
--- a/core/src/test/java/brooklyn/util/task/BasicTaskExecutionPerformanceTest.java
+++ b/core/src/test/java/brooklyn/util/task/BasicTaskExecutionPerformanceTest.java
@@ -158,7 +158,9 @@ public class BasicTaskExecutionPerformanceTest {
// (e.g. 9s for first 1000; 26s for next 1000; 42s for next 1000).
@Test
public void testExecutionManagerPerformance() throws Exception {
- final int NUM_TASKS = 1000;
+ // Was fixed at 1000 tasks, but was running out of virtual memory due to excessive thread creation
+ // on machines which were not able to execute the threads quickly.
+ final int NUM_TASKS = Math.min(500 * Runtime.getRuntime().availableProcessors(), 1000);
final int NUM_TIMES = 10;
final int MAX_ACCEPTABLE_TIME = 7500; // saw 5601ms on buildhive