This patch optimizes the way field trigger trees are computed. Overall,
the resulting trigger trees are mostly identical, but they can now be
determined one by one, which enables an on-demand approach and partial
cache.
Before this patch, getting the first trigger tree proceeded as follows:
- resolve the dependencies of all fields;
- compute the transitive closure of the dependencies of all fields;
- store the transitive closure above as field triggers for all fields
in a cache.
After this patch, getting the first trigger tree proceeded as follows:
- resolve the dependencies of all fields;
- cache them as direct triggers for all fields;
- compute one trigger tree as the transitive closure of the field's
triggers, and cache it.
This optimization is quite effective during the installation of modules,
and is even more effective when the number of fields is large. For
instance, a complete installation with all community modules is now 25%
faster. For a complete installation with all enterprise modules, the
installation time is even 30% less! A medium installation is about 16%
less time.
The optimization also speeds up the first request on a new Odoo worker,
since the minimum time for computing a handful of trigger trees is much
smaller than before. We have measured times for a first request going
from 1.6 seconds to 1 second for posting a message.
We have observed slight differences in trigger trees, but they occur in
places where the tree has redundant branches, in particular with fields
having recursive dependencies. It therefore makes no difference in what
is being triggered or invalidated.
X-original-commit: 68f786d494c3c73a085cd919b348c019f77794e7
Part-of: odoo/odoo#111946