Objective

  1. ExtensionDiscovery can detect the type of an extension faster, if the 'type' property is declared first.
  2. It is not required to declare the 'type' property first.
  3. Most developers are following what core is doing, so we can slightly improve performance by simply leading by example.

Proposed solution

  1. Change all .info.yml files in core to declare the 'type' property first.

  2. While being there, let's also standardize the three required .info.yml file properties to be consistently declared first + in this order:

    type: module
    core: 8.x
    name: Foo
    ...
    

This can be scripted. For the sake of retaining potential comments, intentionally not using a YAML parser/dumper.

Comments

sun’s picture

Title: Move 'type' properties in .info.yml files to be defined first for performance (lead by example). » Move 'type' .info.yml file property first for performance (lead by example)
Issue tags: +Performance, +Test suite performance
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This really helps people to not forget the type: $type key, which is quite annoying, at least was in the past.
Do we throw something if it is not defined?

I do agree that core: 8.x should be above the name as it is required like the type.

webchick’s picture

Ew, I really don't like that. :( From a "human" (module author / downloader) perspective, these files make a lot more sense in a logical sequence which more or less how it's done in HEAD, IMO. With the files as they are in the patch, I need to skim past 2 lines of "noise" in every .info file until I find something useful and unique about it.

Assigning to catch to see if he finds the performance reason compelling to do this.

webchick’s picture

Assigned: Unassigned » catch

Ahem.

catch’s picture

Assigned: catch » Unassigned
Status: Reviewed & tested by the community » Needs review
Issue tags: +needs profiling

Can't tell how compelling it is without profiling.

Also I'm wondering how many requests we actually do where we scan these files and don't eventually go on to parse the YAML anyway?

dawehner’s picture

Ew, I really don't like that. :( From a "human" (module author / downloader) perspective, these files make a lot more sense in a logical sequence which more or less how it's done in HEAD, IMO. With the files as they are in the patch, I need to skim past 2 lines of "noise" in every .info file until I find something useful and unique about it.

ON the other hand it really forces people to not forget this two keys. If you miss either core or type you probably don't see the module in admin/modules which is freaking annoying to be honest.

sun’s picture

Assigned: Unassigned » sun

wondering how many requests we actually do where we scan these files and don't eventually go on to parse the YAML anyway?

That's really hard to tell — in general, the more our code base gets untangled and decoupled, the less we're able to answer this kind of question.

We'd have to write a pretty heavy call invocation tracking tool that would collect all traces based on all possible call chains. IIRC, XDebug has a related add-on along those lines (but I could be wrong), and of course, the data collection is only the smaller part of the challenge.

However, some hopefully more convincing reasons:

  1. The new ExtensionDiscovery scans for all extensions of all types, regardless of which type has been requested.

    This is what allowed us to remove the much behated hook_system_theme_info(), which was required to allow (test) modules to ship with themes previously.

    This aspect increases the possibility of discovering more .info.yml files than files that will be parsed.

  2. ExtensionDiscovery is used in some places that do not involve YAML parsing at all — e.g., Simpletest uses it to locate all available extensions that could possibly have tests.

  3. As @dawehner already mentioned: Consistency.

    Declaring the required properties first is pretty much a standard practice in all meta information file standards that I know of; e.g., composer.json, bower.json, package.json, jquery.[plugin].json, etc.pp.

    Likewise, most of these meta information file standards have a 'type' property, too (cf. Composer). Our use of 'type' is pretty much identical to that. In case a meta information file standard has a 'type', then you normally declare it as one of the first properties.

    Consistency is a huge help for developers to remember to always declare these properties.


Lastly, duly noting:

If our meta files were .json instead of .yml, then the entire parsing aspect would be obsolete/irrelevant, since parsing JSON is lightning-fast. I really wish we had gone with .json files instead. Not necessarily composer.json, just .json. But I guess that ship has sailed... :-(

anavarre queued drupal8.info-type.0.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal8.info-type.0.patch, failed testing.

dawehner’s picture

Adding a related issue

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.

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.

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.

jeroent’s picture

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

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). 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.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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.

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.

andypost’s picture

Version: 9.5.x-dev » 10.0.x-dev
Assigned: sun » Unassigned

still makes sense as less files will be read

andypost’s picture

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

re-roll

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.0.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. 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.