EDIT: I created a Drupal issue for this: https://www.drupal.org/node/2846485
In D8, I have a content type "Event" with a multi-value DateRange field called "Date". I have one single event node, and this event node has 100 values for the date range field (1 daterange value per day for 100 days).
I've created a view that outputs a row for each occurrence of the event. I accomplished this by having the view output Fields, and added the "Title" and "Date" field. For the "Date" field configuration, I have it set so that it will render a row for each value of the field, so 100 rows end up being returned like this:
Without render caching enabled, it takes 20 seconds for the results to render. With render caching enabled, and the cache primed, it takes 0.5 seconds.
With the cache disabled, I would expect it to take a bit longer, but not 40 times longer. The reason I'm testing with the cache disabled is that I don't want my site to be taken down after a cache clear, especially since this view will eventually be on the homepage (although with the result set limited a bit). So I'm interested in doing whatever I can to speed up initial rendering of these items.
I used BlackFire profiler to figure out what's going on. It revealed that
DateRangePlainFormatter::buildDate is called 20,000 times and took 15 seconds of the total 20 second time:
I can sort of figure out the 20,000 number. There are 100 rows output, one for each date occurrence. Then for each row, views must be trying to render all 100 dates AGAIN. And all that happens twice I guess for some reason?
Ideally views would only call out to render the date fields 100 times, one for each date that's output. I would even settle for 200 times, but 20,000 seems like a bug somewhere.
It looks like I'm going to be spending a lot of time looking deep into views rendering, but hopefully someone can save me some time!
Can anyone point me in the right direction on how to solve this?