Updated: Comment #N

Problem/Motivation

Including and executing ::getInfo on each test class consumes memory that cannot be returned to the pool.
We should investigate alternatives to the ::getInfo method that would allow this memory to be freed.
The most logical would be our existing Annotations as that would keep the metadata with the class.
An alternative approach would be yaml, but that would leave the metadata orphaned in an alternate file.

Proposed resolution

Move the ::getInfo method to an annotation

Remaining tasks

Patch

User interface changes

None

API changes

::getInfo replaced with annotations

#1567500: [meta] Pave the way to replace the testing framework with PHPUnit and possibly rewrite Simpletest
Coming from backdrop investigations into memory-usage https://github.com/backdrop/backdrop-issues/issues/78#issuecomment-24485072

Comments

quicksketch’s picture

If you haven't tried it recently, give loading the SimpleTest page in the UI a try. Last I attempted this, it exhausted my 150MB memory limit in PHP. I had to increase it to 200MB to get the page to load. By switching to an approach that doesn't require parsing the PHP classes in memory, you can get an enormous memory savings.

That said, I'd recommend YAML over Annotations. It's the same thing we do for modules themselves, right? If you want a list of modules, read the YAML files. If you want a list of tests, read the YAML files. I didn't benchmark annotations, but from a speed perspective, I would expect a single module.tests.yml file to be a lot faster than needing to discover and then parse all the individual test classes. Though I'd say the same for plugins too...

larowlan’s picture

Note this is a stopgap measure as ideally we won't have a Simpletest UI in D9 for all the reasons detailed in #1567500: [meta] Pave the way to replace the testing framework with PHPUnit and possibly rewrite Simpletest

quicksketch’s picture

ideally we won't have a Simpletest UI in D9

Even if there's no UI, if there's a mechanism for listing tests the static getInfo() approach is still going to consume a lot of memory parsing all the available tests.

Over in Backdrop-land, I filed a PR that moves all the test information to .info files. The results were great:

Memory usage getInfo() approach: 45.5 MB
Memory usage .info file approach: 700 KB

Drupal savings would probably be greater because it has more tests.

Full test details are at https://github.com/backdrop/backdrop-issues/issues/81#issuecomment-26208301

quicksketch’s picture

Issue summary: View changes

Updated issue summary.

rodrigoaguilera’s picture

Version: 9.x-dev » 9.0.x-dev

The 9.0.x branch will open for development soon, and the placeholder 9.x branch should no longer be used. Only issues that require a new major version should be filed against 9.0.x (for example, removing deprecated code or updating dependency major versions). New developments and disruptive changes that are allowed in a minor version should be filed against 8.9.x, and significant new features will be moved to 9.1.x at committer discretion. For more information see the Allowed changes during the Drupal 8 and 9 release cycles and the Drupal 9.0.0 release plan.