There are a number of problems in ProductVariationFieldRenderer:
1) Field rendering is significantly slower than it needs to be.
Instead of renderField() calling renderFields() and taking the field it's interested in, we do the opposite: renderFields() calls renderField() on each field name separately. That means that for each field Drupal resolves the entity display (entity query + entity load), runs all hooks, does all post-processing. And what's most absurd, none of our code even uses renderField(), we only use renderFields(), so we can't say we prioritized single-field rendering performance.
2) getFieldDefinitions() is a public method that should probably be protected. It loads all field definitions just to determine which base fields to ignore (compared against the list in getAllowedBaseFields()). It would be much cheaper for ProductVariationFieldRenderer to simply have a list of base fields to skip.
3) renderFields() returns fields that do not have a formatter configured (cause they're hidden in the view display).
This has a cost, cause we output ajax commands for those empty fields as well, even though nothing can be done with them.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3010225-2.patch | 12.77 KB | bojanz |
Comments
Comment #2
bojanz commentedRemoved getFieldDefinitions() and the field whitelist. Made renderFields() render all fields at once. Expanded tests.
Comment #4
bojanz commented