Problem/Motivation
Add a class loader like this:
spl_autoload_register( function ($class_name) {
file_put_contents(__DIR__ . '/classes.txt', $class_name . "\n", FILE_APPEND);
},
FALSE, TRUE);
It generates a classes.txt file.
Look at that file like this:
sort classes.txt | uniq -c
You'll see stuff like this:
2 Drupal\Core\Annotation\PluginID
3 Drupal\Core\Annotation\Translation
5 Drupal\Core\Annotation\code
3 Drupal\Core\Annotation\end
3 Drupal\Core\Annotation\end_code
5 Drupal\Core\Annotation\endcode
25 Drupal\Core\Annotation\ingroup
1 Drupal\Core\Annotation\property
11 Drupal\Core\Annotation\see
2 Drupal\Core\Annotation\todo
This means that the classloader is being asked to autoload, for instance, Drupal\Core\Annotation\ingroup
25 times in a front page load.
That's because the annotation system isn't filtering out known-bad annotations.
At absolute best this means that the autoloader has to waste time dealing with this stuff, and at worst has to do a file_exists()
for each of these requests.
Proposed resolution
Have the annotation system filter out known annotations.