Composer was released 8 years ago which is a predecessor of PEAR which is a PHP package manager. Composer has become the de facto package manager for most of the PHP projects including Drupal.

Composer although have served well, however, there has been always an issue with performance and memory consumption. The upcoming release of Composer version 2 aims to be more performant in terms of memory and faster download time.

Read more about it:

I tried out Composer 2 (2.0-dev) and compared it with Composer 1 (1.10.9) in a Drupal 9 project executing the various tasks which are used on a general Drupal project.

Installing Composer v2

Composer self update to v2 snapshot

To install the dev version of Composer version 2 update composer to the snapshot version using composer self-update --spanshot. Most likely, hirak/prestissimo will be installed which is not compatible with Composer v2 so disable the plugin composer --no-plugins. To roll back to the previous version composer self-update --1

All the tests are done on my MacBook Pro 16 running on Catalina 10.15.6, first done on an empty cache, then by a new test after the cache is primed.

Create a new project

Create new project task comparison

composer create-project drupal/recommended-project site
Without Cache

Composer v1: 28.03 seconds
Composer v2: 22.68 seconds
Performance improvement: ~23%

With cache

Composer v1: 10.31 seconds
Composer v2: 7.04 seconds
Performance improvement: ~46%

Install a module/theme

Install new module/theme task comparison

composer require drupal/pathauto
Without Cache

Composer v1: 31.27 seconds
Composer v2: 12.76 seconds
Performance improvement: ~145%

With cache

Composer v1: 19.00 seconds
Composer v2: 5.39 seconds
Performance improvement: ~822%

Remove a module/theme

Remove a module/theme task comparison

composer remove drupal/pathauto
Without Cache

Composer v1: 34.06 seconds
Composer v2: 652.37 milliseconds
Performance improvement: ~5,120%

With cache

Composer v1: 10.26 seconds
Composer v2: 706.17 milliseconds
Performance improvement: ~1,352%

Install dependencies with composer.lock

Composer install dependencies comparison with composer.lock

composer install
Without Cache

Composer v1: 71.85 seconds
Composer v2: 40.51 seconds
Performance improvement: ~77%

With cache

Composer v1: 9.91 seconds
Composer v2: 9.20 seconds
Performance improvement: ~7%

Updating core with composer

For this Drupal core was updated from 8.9 to 9.0.2

Update core with composer

composer update --with-dependencies
Without Cache

Composer v1: 38.73 seconds
Composer v2: 32.13 seconds
Performance improvement: ~20%

With cache

Composer v1: 18.75 seconds
Composer v2: 9.71 seconds
Performance improvement: ~93%

Action Composer V1   Composer v2  
  Without cache With cache Without cache With cache
Create project 28.03 secs 10.31 secs 22.68 secs 7.04 secs
Require 31.27 secs 19.00 secs 12.76 secs 5.39 secs
Remove 34.06 secs 10.26 secs 652.37 millis 706.17 millis
Install 71.85 secs 9.91 secs 40.51 secs 9.20 secs
Update 38.73 secs 18.67 secs 32.13 secs 9.71 secs


So, Composer version 2 is definitely faster for the usual tasks needed for Drupal projects. It will be mostly compatible with your existing workflows while bringing some more great new features. Check out Composer 2 Development Update