diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index f9f97ecaa8..96b741148d 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -41,6 +41,13 @@
    */
   protected $configDirectories = [];
 
+  /**
+   * Setting unique apcu prefix. See Settings::getApcuPrefix().
+   *
+   * @var bool
+   */
+  protected $apcuEnsureUniquePrefix = FALSE;
+
   /**
    * Prepares site settings and services before installation.
    */
@@ -83,6 +90,10 @@ protected function prepareSettings() {
       'value' => $this->originalProfile,
       'required' => TRUE,
     ];
+    $settings['settings']['apcu_ensure_unique_prefix'] = (object) [
+      'value' => $this->apcuEnsureUniquePrefix,
+      'required' => TRUE,
+    ];
     $this->writeSettings($settings);
     // Allow for test-specific overrides.
     $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php';
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 0e0ea2afd4..31cb171fa5 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -186,9 +186,18 @@ function simpletest_run_phpunit_tests($test_id, array $unescaped_test_classnames
   $phpunit_file = simpletest_phpunit_xml_filepath($test_id);
   simpletest_phpunit_run_command($unescaped_test_classnames, $phpunit_file, $status, $output);
 
+  $mem = '0';
+  if (is_array($output) && count($output)) {
+    $mem = array_filter($output, function($v) { return stripos($v, 'Memory: '); });
+    $mem = !empty($mem) ? explode('Memory: ', array_pop($mem)) : '';
+    $mem = !empty($mem) && is_array($mem) ? array_pop($mem) : '0';
+    $mem = trim(str_ireplace('MB', '', $mem));
+    $mem = (int)(floatval($mem)*1048576);
+  }
+
   $rows = [];
   if ($status == TestStatus::PASS) {
-    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file);
+    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file, $mem);
   }
   else {
     $rows[] = [
@@ -242,7 +251,7 @@ function simpletest_summarize_phpunit_result($results) {
         '#pass' => 0,
         '#fail' => 0,
         '#exception' => 0,
-        '#debug' => 0,
+        '#debug' => $result['message'],
       ];
     }
 
@@ -260,7 +269,7 @@ function simpletest_summarize_phpunit_result($results) {
         break;
 
       case 'debug':
-        $summaries[$result['test_class']]['#debug']++;
+        //$summaries[$result['test_class']]['#debug']++;
         break;
     }
   }
@@ -777,7 +786,7 @@ function simpletest_mail_alter(&$message) {
  *   {simpletest}. If the phpunit_xml_file does not have any contents then the
  *   function will return NULL.
  */
-function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
+function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file, $mem = '0') {
   $contents = @file_get_contents($phpunit_xml_file);
   if (!$contents) {
     return;
@@ -785,7 +794,7 @@ function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
   $records = [];
   $testcases = simpletest_phpunit_find_testcases(new SimpleXMLElement($contents));
   foreach ($testcases as $testcase) {
-    $records[] = simpletest_phpunit_testcase_to_row($test_id, $testcase);
+    $records[] = simpletest_phpunit_testcase_to_row($test_id, $testcase, $mem);
   }
   return $records;
 }
@@ -841,8 +850,8 @@ function simpletest_phpunit_find_testcases(\SimpleXMLElement $element, \SimpleXM
  * @return array
  *   An array containing the {simpletest} result row.
  */
-function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcase) {
-  $message = '';
+function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcase, $mem = '0') {
+  $message = $mem;
   $pass = TRUE;
   if ($testcase->failure) {
     $lines = explode("\n", $testcase->failure);
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 407d87a34f..597391f3f8 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -142,6 +142,11 @@
 }
 
 $test_list = simpletest_script_get_test_list();
+if (in_array('Drupal\FunctionalTests\Update\UpdatePathTestBaseTest', $test_list)) {
+  $test_list = array_fill(0, 500, 'Drupal\FunctionalTests\Update\UpdatePathTestBaseTest');
+} else {
+  $test_list = [];
+}
 
 // Try to allocate unlimited time to run the tests.
 drupal_set_time_limit(0);
@@ -664,6 +669,9 @@ function simpletest_script_execute_batch($test_classes) {
   $total_status = SIMPLETEST_SCRIPT_EXIT_SUCCESS;
 
   // Multi-process execution.
+  $directory = PublicStream::basePath() . '/simpletest';
+  file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+  $logfile = $directory . '/mem-child-proc.log';
   $children = array();
   while (!empty($test_classes) || !empty($children)) {
     while (count($children) < $args['concurrency']) {
@@ -693,6 +701,13 @@ function simpletest_script_execute_batch($test_classes) {
         exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
       }
 
+      $apcuinfo = ';;';
+      if (function_exists('apcu_sma_info')) {
+        $info = apcu_sma_info(TRUE);
+        $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'];
+      }
+      file_put_contents($logfile, gmdate('YmdHis') . ';+;' . $test_id . ';' . $test_class . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
+
       // Register our new child.
       $children[] = array(
         'process' => $process,
@@ -743,6 +758,13 @@ function simpletest_script_execute_batch($test_classes) {
           simpletest_script_cleanup($child['test_id'], $child['class'], $status['exitcode']);
         }
 
+        $apcuinfo = ';;';
+        if (function_exists('apcu_sma_info')) {
+          $info = apcu_sma_info(TRUE);
+          $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'];
+        }
+        file_put_contents($logfile, gmdate('YmdHis') . ';-;' . $child['test_id'] . ';' . $child['class'] . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
+
         // Remove this child.
         unset($children[$cid]);
       }
@@ -806,6 +828,7 @@ function simpletest_script_run_one_test($test_id, $test_class) {
       $test->dieOnFail = (bool) $args['die-on-fail'];
       $test->verbose = (bool) $args['verbose'];
       $test->run($methods);
+      $test->results['#debug'] = memory_get_peak_usage(TRUE);
       simpletest_script_reporter_display_summary($test_class, $test->results);
 
       $status = SIMPLETEST_SCRIPT_EXIT_SUCCESS;
@@ -1186,7 +1209,7 @@ function simpletest_script_reporter_display_summary($class, $results) {
   // Output all test results vertically aligned.
   // Cut off the class name after 60 chars, and pad each group with 3 digits
   // by default (more than 999 assertions are rare).
-  $output = vsprintf('%-60.60s %10s %9s %14s %12s', array(
+  $output = vsprintf('%-80.80s %10s %9s %14s %12s', array(
     $class,
     $results['#pass'] . ' passes',
     !$results['#fail'] ? '' : $results['#fail'] . ' fails',
diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
index 4aca50032b..2ea83745d5 100644
--- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
+++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
@@ -165,7 +165,7 @@ protected function setUp() {
     $this->runDbTasks();
     // Allow classes to set database dump files.
     $this->setDatabaseDumpFiles();
-
+    $this->log('after setDatabaseDumpFiles()');
     // We are going to set a missing zlib requirement property for usage
     // during the performUpgrade() and tearDown() methods. Also set that the
     // tests failed.
@@ -182,8 +182,9 @@ protected function setUp() {
 
     // Install Drupal test site.
     $this->prepareEnvironment();
+    $this->log('before installDrupal()');
     $this->installDrupal();
-
+    $this->log('after installDrupal()');
     // Add the config directories to settings.php.
     drupal_install_config_directories();
 
@@ -194,33 +195,36 @@ protected function setUp() {
     $this->replaceUser1();
 
     require_once \Drupal::root() . '/core/includes/update.inc';
-
+    $this->log('after require update.inc');
     // Setup Mink.
     $session = $this->initMink();
-
     $cookies = $this->extractCookiesFromRequest(\Drupal::request());
     foreach ($cookies as $cookie_name => $values) {
       foreach ($values as $value) {
         $session->setCookie($cookie_name, $value);
       }
     }
-
     // Set up the browser test output file.
     $this->initBrowserOutputFile();
+    //$this->log('setUp: end');
   }
 
   /**
    * {@inheritdoc}
    */
   public function installDrupal() {
+    $this->log('installDrupal: start');
     $this->initUserSession();
+    $this->log('installDrupal: after initUserSession()');
     $this->prepareSettings();
+    $this->log('installDrupal: after prepareSettings()');
     $this->doInstall();
+    $this->log('doInstall: after');
     $this->initSettings();
-
     $request = Request::createFromGlobals();
     $container = $this->initKernel($request);
     $this->initConfig($container);
+    $this->log('installDrupal: end');
   }
 
   /**
@@ -311,6 +315,7 @@ protected function prepareSettings() {
    * Helper function to run pending database updates.
    */
   protected function runUpdates() {
+    $this->log('start runUpdates');
     if (!$this->zlibInstalled) {
       $this->fail('Missing zlib requirement for update tests.');
       return FALSE;
@@ -325,15 +330,17 @@ protected function runUpdates() {
         ],
       ],
     ]);
-
     $this->drupalGet($this->updateUrl);
+    $this->log('after updateUrl');
     $this->clickLink(t('Continue'));
-
+    $this->log('after Continue');
     $this->doSelectionTest();
+    $this->log('after doSelectionTest()');
     // Run the update hooks.
     $this->clickLink(t('Apply pending updates'));
+    $this->log('after Apply pending updates');
     $this->checkForMetaRefresh();
-
+    $this->log('after checkForMetaRefresh');
     // Ensure there are no failed updates.
     if ($this->checkFailedUpdates) {
       $this->assertNoRaw('<strong>' . t('Failed:') . '</strong>');
@@ -359,7 +366,7 @@ protected function runUpdates() {
       // Reset the static cache of drupal_get_installed_schema_version() so that
       // more complex update path testing works.
       drupal_static_reset('drupal_get_installed_schema_version');
-
+      $this->log('after drupal_static_reset');
       // The config schema can be incorrect while the update functions are being
       // executed. But once the update has been completed, it needs to be valid
       // again. Assert the schema of all configuration objects now.
@@ -384,6 +391,7 @@ protected function runUpdates() {
         }
       }
     }
+    $this->log('end runUpdates');
   }
 
   /**
@@ -433,4 +441,15 @@ protected function doSelectionTest() {
     // and implement their required tests.
   }
 
+
+  public function log($phase='') {
+    $logfile = $this->root . '/sites/default/files/simpletest/mem-update-log.log';
+    $apcuinfo = ';;;;;;;;';
+    if (function_exists('apcu_sma_info')) {
+      $info = apcu_sma_info(TRUE); $more = apcu_cache_info(TRUE);
+      $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'].';'.$more['num_slots'].';'.$more['num_hits'].';'.$more['num_misses'].';'.$more['num_inserts'].';'.$more['num_entries'].';'.$more['expunges'];
+    }
+    $test_name = $this->databasePrefix . '/' . $this->getName();
+    file_put_contents($logfile, gmdate('YmdHis') . ';'. "$test_name: $phase" .';' . memory_get_peak_usage(TRUE) . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
+  }
 }
diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php
index a375db7e8c..3ab9d93d39 100644
--- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php
@@ -31,10 +31,10 @@ protected function setDatabaseDumpFiles() {
    * Tests that the database was properly loaded.
    */
   public function testDatabaseLoaded() {
+    //$this->log('test start');
     foreach (['user', 'node', 'system', 'update_test_schema'] as $module) {
       $this->assertEqual(drupal_get_installed_schema_version($module), 8000, SafeMarkup::format('Module @module schema is 8000', ['@module' => $module]));
     }
-
     // Ensure that all {router} entries can be unserialized. If they cannot be
     // unserialized a notice will be thrown by PHP.
 
@@ -68,12 +68,14 @@ public function testDatabaseLoaded() {
       $this->assertEqual('on', $database->query("SHOW standard_conforming_strings")->fetchField());
       $this->assertEqual('escape', $database->query("SHOW bytea_output")->fetchField());
     }
+    //$this->log('test end');
   }
 
   /**
    * Test that updates are properly run.
    */
   public function testUpdateHookN() {
+    //$this->log('test start');
     // Increment the schema version.
     \Drupal::state()->set('update_test_schema_version', 8001);
     $this->runUpdates();
@@ -92,6 +94,7 @@ public function testUpdateHookN() {
     $this->assertEqual(drupal_get_installed_schema_version('update_test_schema', TRUE), 8001);
     // Ensure the index was added for column a.
     $this->assertTrue(db_index_exists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.');
+    //$this->log('test end');
   }
 
 }
diff --git a/index.php b/index.php
index 750dc282dc..ed58d191f5 100644
--- a/index.php
+++ b/index.php
@@ -20,3 +20,11 @@
 $response->send();
 
 $kernel->terminate($request, $response);
+
+$logfile = $kernel->getAppRoot() . '/sites/default/files/simpletest/mem-index.log';
+$apcuinfo = ';;;;;;;;';
+if (function_exists('apcu_sma_info')) {
+  $info = apcu_sma_info(TRUE); $more = apcu_cache_info(TRUE);
+  $apcuinfo = $info['avail_mem'].';'.$info['seg_size'].';'.$info['num_seg'].';'.$more['num_slots'].';'.$more['num_hits'].';'.$more['num_misses'].';'.$more['num_inserts'].';'.$more['num_entries'].';'.$more['expunges'];
+}
+file_put_contents($logfile, gmdate('YmdHis') . ';I;' . memory_get_peak_usage(TRUE) . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
diff --git a/update.php b/update.php
index 59e808ed24..6c31c3b850 100644
--- a/update.php
+++ b/update.php
@@ -29,3 +29,6 @@
 $response->send();
 
 $kernel->terminate($request, $response);
+
+$logfile = $kernel->getAppRoot() . '/sites/default/files/simpletest/mem-update.log';
+file_put_contents($logfile, gmdate('YmdHis') . ';U;' . memory_get_peak_usage(TRUE) . PHP_EOL, FILE_APPEND | LOCK_EX);
