Problem/Motivation
I recently upgraded jsonapi + jsonapi_extras from 1.7 -> 1.10 and rc1 -> rc5 respectively. Our frontend is now taking 10-15 seconds longer to fetch each set of 50 nodes it is requesting. I profiled the request using xhprof and with the help of Gabriel, was able to identify that ConfigurableResourceTypeRepository::getResourceConfigs was invoked 500+ times for the single request, thus invoking EntityStorageBase::loadMultiple 500+ times:
$resource_configs = $this->entityTypeManager
->getStorage('jsonapi_resource_config')
->loadMultiple($resource_config_ids);
Proposed resolution
Store $resource_configs in a property on the class or in cache so that subsequent calls do not need to load all resource configs again. Will post a patch shortly.
I believe this was introduced in #2941095: ResourceTypeRepository loads all configuration for every ->get($entity_type_id, $bundle).
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | jsonapi_extras-redundant-loading-of-resource-configs-2948512-3-D8.patch | 1.76 KB | malik.kotob |
Comments
Comment #2
malik.kotob commentedComment #3
malik.kotob commentedComment #4
gabesulliceComment #5
gabesulliceSetting this as critical. Anyone using extras will be experiencing truly significant slow downs because of this.
Comment #6
e0ipsoThanks for this patch. This is now fixed!