Change record status: 
Project: 
Introduced in branch: 
9.4.x
Introduced in version: 
9.4.0
Description: 

The \Drupal\Core\Config\StorageCopyTrait is now optimized for slow write operations.
This means that instead of deleting everything in the target storage and then reading everything in the source storage and writing it to the target storage, the replaceStorageContents method of the trait now reads the source and the target storage and updates the target storage only when necessary.

The trait is by default used in \Drupal\Tests\ConfigTestTrait::copyConfig

Pseudo-code to illustrate:
Before:

      // First delete everything.
      foreach ($target_collection->listAll() as $name) {
        $target_collection->delete($name);
      }
      // Then copy everything.
      foreach ($source_collection->listAll() as $name) {
        $data = $source_collection->read($name);
        $target_collection->write($name, $data);
      }

After:

      $names = $source_collection->listAll();
      // First we delete all the config which shouldn't be in the target.
      foreach (array_diff($target_collection->listAll(), $names) as $name) {
        $target_collection->delete($name);
      }
      // Update the target collection if the data is different.
      foreach ($names as $name) {
        $data = $source_collection->read($name);
        if ($target_collection->read($name) !== $data) {
          $target_collection->write($name, $data);
        }
      }
Impacts: 
Module developers