Massive performance issues, especially on save
On recent Form Processor versions, I notice that pressing "Save" returns success quickly, but doesn't save my changes. If I press "Save" a second time, my changes are saved, but it takes a very long time to save - and if the Form Processor is big enough, it will slow down the whole server with PHP taking up a whole CPU.
UPDATE There are three factors that contribute to this bug:
- Post hooks are now present on all FormProcessor entities.
-
CRM_Core_BAO_Managed::isApi4ManagedType()
, as of Civi 5.45, is called on everyhook_civicrm_post
. - This calls
CRM_FormProcessor_BAO_FormProcessorInstance::getValues()
, which is quite slow, and not cached, in order to build the API entity list - even if they're unnecessary.
On a site with 18 Form Processor instances, 172 actions, and 621 inputs, it takes 20 seconds to save a form processor with 20 inputs. With 100 inputs, it brings down the server.
I have a PR I'll submit tomorrow that optimizes CRM_FormProcessor_BAO_FormProcessorInstance::getValues()
, which results in a speedup of orders of magnitude.
We could further optimize the save speed - we can cache CRM_FormProcessor_BAO_FormProcessorInstance::getValues()
, for instance. If there's a way to reduce (recursive) calls to CRM_Utils_API_HTMLInputCoder::decodeOutput()
that would also save us a lot of time, per XDebug Profiler. But the main issue is resolved.