diff --git a/core/core.services.yml b/core/core.services.yml
index 9e82af7d4b..b3e14554ea 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -186,6 +186,7 @@ services:
     arguments: ['@database']
     tags:
       - { name: cache_tags_invalidator}
+      - { name: persist }
   cache.backend.chainedfast:
     class: Drupal\Core\Cache\ChainedFastBackendFactory
     arguments: ['@settings']
diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
index 0c4faee341..d98e8ef814 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
@@ -103,6 +103,9 @@ public function isValid($checksum, array $tags) {
    *   The calculated checksum.
    */
   protected function calculateChecksum(array $tags) {
+    if (!empty($tags) && \Drupal::service('cache_tags.invalidator.checksum') !== $this) {
+      throw new \Exception('An obsolete service instance is used.');
+    }
     $checksum = 0;
 
     $query_tags = array_diff($tags, array_keys($this->tagCache));
diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index 2cf34bd22f..5ebf3073e4 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -151,6 +151,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
 
         // Save this data without checking schema. This is a performance
         // improvement for module installation.
+        $extension_config = \Drupal::configFactory()->getEditable('core.extension');
         $extension_config
           ->set("module.$module", 0)
           ->set('module', module_config_sort($extension_config->get('module')))
diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
index 075c982773..30b1ac0a70 100644
--- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
@@ -269,6 +269,16 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
 
     $account_values = $form_state->getValue('account');
 
+    // We precreated user 1 with placeholder values. Let's save the real values.
+    $account = $this->userStorage->load(1);
+    $account->init = $account->mail = $account_values['mail'];
+    $account->roles = $account->getRoles();
+    $account->activate();
+    $account->timezone = $form_state->getValue('date_default_timezone');
+    $account->pass = $account_values['pass'];
+    $account->name = $account_values['name'];
+    $account->save();
+
     // Enable update.module if this option was selected.
     $update_status_module = $form_state->getValue('enable_update_status_module');
     if ($update_status_module) {
@@ -284,16 +294,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
       }
     }
 
-    // We precreated user 1 with placeholder values. Let's save the real values.
-    $account = $this->userStorage->load(1);
-    $account->init = $account->mail = $account_values['mail'];
-    $account->roles = $account->getRoles();
-    $account->activate();
-    $account->timezone = $form_state->getValue('date_default_timezone');
-    $account->pass = $account_values['pass'];
-    $account->name = $account_values['name'];
-    $account->save();
-
     // Record when this install ran.
     $this->state->set('install_time', $_SERVER['REQUEST_TIME']);
   }
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 6670e5acc0..542f4d8707 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;
     }
   }
@@ -773,7 +782,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;
@@ -781,7 +790,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;
 }
@@ -837,8 +846,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 5a8ecd99c2..ae54f7aae4 100644
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -665,6 +665,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 = [];
   while (!empty($test_classes) || !empty($children)) {
     while (count($children) < $args['concurrency']) {
@@ -694,6 +697,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[] = [
         'process' => $process,
@@ -744,6 +754,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]);
       }
@@ -807,6 +824,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;
@@ -1187,7 +1205,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', [
+  $output = vsprintf('%-80.80s %10s %9s %14s %12s', [
     $class,
     $results['#pass'] . ' passes',
     !$results['#fail'] ? '' : $results['#fail'] . ' fails',
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..3537972494 100644
--- a/update.php
+++ b/update.php
@@ -29,3 +29,11 @@
 $response->send();
 
 $kernel->terminate($request, $response);
+
+$logfile = $kernel->getAppRoot() . '/sites/default/files/simpletest/mem-update.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') . ';U;' . memory_get_peak_usage(TRUE) . ';' . $apcuinfo . PHP_EOL, FILE_APPEND | LOCK_EX);
