Performance optimization: Unify the event and process initialization layer
Problem/Motivation
Follow-up from #3277468: Performance optimization: dynamic event subscription:
We now have 3 initialization layers:
- The event subscriber that reads from state
- The ECA entity storage that reads from cache (EcaStorage::$configByEvents)
- The processor service that loads all event objects from an ECA config:
foreach ($eca->getUsedEvents() as $ecaEvent) {
Think this initialization process can be further optimized. For example, it may be considered to just put in all initialization-relevant values into one array and put it into state. That might reduce some I/O (point 1 and 2) and object instantiation overhead (point 3).
Drupal's state service is already using a static in-memory cache once a value got loaded. That means that we can already make use of that service's caching here.
This optimization will include some heavy changes, also on the processor, which needs to be thoroughly tested.
When addressing this, it can be validated whether we can reduce the event's complexity regards its mostly redundant logic that is put in to the applies and appliesForLazyLoadingWildcard method. If done right, we only need one method.