-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering DropdownField can be really slow for many instances #10174
Comments
So indeed it seems that using the template slow things down quite a bit and using plain php code is faster at least from what i can tell (it's not exactly easy to compare from within a complex project) I think it's probably worth dropping the template that is not adding much value nevertheless but maybe more testing needs to be done. I've updated |
I had some similar experiences (related to other FormFields) that using a lot of template calls causes serious performance problems. |
Agreed, we have a component for providing some kind of inline editing by using form fields for editing nested entities. When switching some hidden fields (used for storing internal information like sort order) from templates to plain html strings it resulted in a significant performance improvement. From my experience having xdebug enabled can have an extreme performance impact in Silverstripe projects. You might want to try it without, I assume the impact in a production environment will be a lot smaller. Nevertheless I would welcome any performance improvement to the template layer :-) |
it seems that every call to $scope->locally() is really slow i would qualify this as a design flaw from the template itself. it's quite visible for a dropdown with lots of options, but it's basically affecting all form fields the long term solution would be:
|
Affected Version
4.x
Description
I have a project with an editable gridfield with many dropdowns (something like 50 rows and 2 dropdowns per row) and it's super slow to render. Here is a screenshot given by the DebugBar in the admin. It takes about 9 seconds to render all the dropdowns (it's faster on production, but still quite slow).
(the CMSTabSet is also super slow, but that's the next issue i'll be handling :) )
In the meantime, i created this
https://github.com/lekoala/silverstripe-base/blob/master/src/Forms/FastDropdownField.php
which is not really a solution, but at least it works for my use case and make the page much faster where i can prerender the template and avoid calling the view engine each time which seem to be the culprit, because it takes less than 1s now.. should be also be there are also a couple of other dropdowns in other tabs).
Steps to Reproduce
Create an editable gridfield that is not paginated with many dropdowns. Here is some sample code below, simplified for the purposes of this ticket (not tested or isolated on a fresh project).
Maybe worth exploring
Simplifying the rendering by not using the view engine to render the option list. I'm going to explore that as well (would probably be cleaner than what i did) and update this issue if I found anything
The text was updated successfully, but these errors were encountered: