Problem/Motivation

If you look at the following services definitions you will see that there are quite of them which don't need to be public:

  asset.css.collection_optimizer:
    class: Drupal\Core\Asset\CssCollectionOptimizer
    arguments: [ '@asset.css.collection_grouper', '@asset.css.optimizer', '@asset.css.dumper', '@state' ]
  asset.css.optimizer:
    class: Drupal\Core\Asset\CssOptimizer
  asset.css.collection_grouper:
    class: Drupal\Core\Asset\CssCollectionGrouper
  asset.css.dumper:
    class: Drupal\Core\Asset\AssetDumper
  asset.js.collection_renderer:
    class: Drupal\Core\Asset\JsCollectionRenderer
    arguments: [ '@state' ]
  asset.js.collection_optimizer:
    class: Drupal\Core\Asset\JsCollectionOptimizer
    arguments: [ '@asset.js.collection_grouper', '@asset.js.optimizer', '@asset.js.dumper', '@state' ]
  asset.js.optimizer:
    class: Drupal\Core\Asset\JsOptimizer
  asset.js.collection_grouper:
    class: Drupal\Core\Asset\JsCollectionGrouper
  asset.js.dumper:
    class: Drupal\Core\Asset\AssetDumper
  library.discovery:
    class: Drupal\Core\Asset\LibraryDiscovery
    arguments: ['@library.discovery.collector']

The following could be marked as public: false

  • library.discovery.parser
  • library.discovery.collector
  • asset.js.collection_grouper
  • asset.js.dumper
  • asset.js.optimizer
  • asset.css.collection_grouper
  • asset.css.dumper
  • asset.css.optimizer

Proposed resolution

Mark them as public: falseand let the testbot decide whether this is okay.

Remaining tasks

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task, because there is no real problem
Issue priority Normal because the impact is not high
Prioritized changes The main goal of this issue is
to improve performance.

Comments

yannisc’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

You mean something like that?

dawehner’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Awesome work!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: Mark-a-couple-of-asset-services-as-non-public-2354705.patch, failed testing.

yannisc’s picture

Status: Needs work » Needs review
StatusFileSize
new1.63 KB

Thanks, dawehner!

I updated the patch, as the original one does not apply any more.

Crell’s picture

Status: Needs review » Reviewed & tested by the community

And back.

wim leers’s picture

Component: theme system » asset library system

AFAICT this does not have negative consequences for contrib: they can still override all of the services, including those marked as private.

It does look like it might make alternative asset processing pipeline implementations, that use these services in a different way a bit more difficult, but AFAIK it's still possible to make private services public again by having a container rebuild event listener.

Finally, it's easy to make private services public if we want to do that later; that'd be an API addition, the reverse direction is an API break.

Assuming I've made no mistakes in the above: +1 :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed af83168 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation for to the issue summary.

  • alexpott committed af83168 on 8.0.x
    Issue #2354705 by yannisc: Mark a couple of asset services as non public
    
webchick’s picture

Over at #2378737: Consider not executing hook_library_(info)_alter() *per* library, but once for all this issue is cited as causing a 150ms slowdown in testbot runs. Adding as a related issue for now, but basically I think we should just roll this back.

wim leers’s picture

That is actually due to a Symfony bug, this patch didn't do anything wrong.

alexpott’s picture

Status: Fixed » Needs work

I agree with @webchick reverted this. We can still do this because having unnecessary public services is a performance hit. But we need to ensure that doing this does not introduce a far bigger perf regression. According to @dawehner the problem is caused by https://github.com/symfony/symfony/issues/12924.

  • alexpott committed 6c46669 on 8.0.x
    Revert "Issue #2354705 by yannisc: Mark a couple of asset services as...
alexpott’s picture

re #10 I agree but lets get the test performance benefits and ensure that a patch that is supposed to deliver those benefits does - which means we need to do fix upstream first.

wim leers’s picture

Fair enough :)

wheatpenny’s picture

Issue tags: -Novice

I am removing the Novice Tag from this issue as there are no remaining tasks.

  • alexpott committed 6c46669 on 8.1.x
    Revert "Issue #2354705 by yannisc: Mark a couple of asset services as...
  • alexpott committed af83168 on 8.1.x
    Issue #2354705 by yannisc: Mark a couple of asset services as non public
    

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • alexpott committed af83168 on 8.3.x
    Issue #2354705 by yannisc: Mark a couple of asset services as non public
    
  • alexpott committed 6c46669 on 8.3.x
    Revert "Issue #2354705 by yannisc: Mark a couple of asset services as...

  • alexpott committed af83168 on 8.3.x
    Issue #2354705 by yannisc: Mark a couple of asset services as non public
    
  • alexpott committed 6c46669 on 8.3.x
    Revert "Issue #2354705 by yannisc: Mark a couple of asset services as...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • alexpott committed af83168 on 8.4.x
    Issue #2354705 by yannisc: Mark a couple of asset services as non public
    
  • alexpott committed 6c46669 on 8.4.x
    Revert "Issue #2354705 by yannisc: Mark a couple of asset services as...

  • alexpott committed af83168 on 8.4.x
    Issue #2354705 by yannisc: Mark a couple of asset services as non public
    
  • alexpott committed 6c46669 on 8.4.x
    Revert "Issue #2354705 by yannisc: Mark a couple of asset services as...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

cyb_tachyon’s picture

Noting here that https://github.com/symfony/symfony/issues/12924 was closed soon after it was opened as "Won't Fix / Not a Bug".

narendra.rajwar27’s picture

Assigned: Unassigned » narendra.rajwar27
narendra.rajwar27’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB

Patch from comment #4, re-rolled and updated for 8.9.x branch.

kristen pol’s picture

Version: 8.9.x-dev » 9.1.x-dev
Issue tags: +Needs reroll

If this is still relevant, it needs a reroll for 9.1.x.

alexpott’s picture

We still need. to look into the performance regression this caused originally. In Symfony world public services are very rare in fact we have to force our container to make services public by default.

narendra.rajwar27’s picture

StatusFileSize
new1.89 KB

Patch Re-roll for 9.1.x.

narendra.rajwar27’s picture

Assigned: narendra.rajwar27 » Unassigned

un-assigning the issue. Please review.

alexpott’s picture

@narendra.rajwar27 if you want this issue to progress then you need to work on #9 - ie. the performance issue caused when we committed the patch.

kristen pol’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

Moving back to needs work per #36.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.