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.
Files: 
CommentFileSizeAuthor
#4 Mark-a-couple-of-asset-services-as-non-public-2354705-2.patch1.63 KByannisc
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 81,820 pass(es).
[ View ]
#1 Mark-a-couple-of-asset-services-as-non-public-2354705.patch1.59 KByannisc
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch Mark-a-couple-of-asset-services-as-non-public-2354705.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

yannisc’s picture

Status:Active» Needs review
StatusFileSize
new1.59 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch Mark-a-couple-of-asset-services-as-non-public-2354705.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 81,820 pass(es).
[ View ]

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 :)