|
| 1 | +.. image:: https://odoo-community.org/readme-banner-image |
| 2 | + :target: https://odoo-community.org/get-involved?utm_source=readme |
| 3 | + :alt: Odoo Community Association |
| 4 | + |
| 5 | +========================= |
| 6 | +Field Trigger Tree Warmup |
| 7 | +========================= |
| 8 | + |
| 9 | +.. |
| 10 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 11 | + !! This file is generated by oca-gen-addon-readme !! |
| 12 | + !! changes will be overwritten. !! |
| 13 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 14 | + !! source digest: sha256:c32021bf286316f53f09e2a7ef5dce116ebfce5f52d8584ad1d093a4ca6a9b76 |
| 15 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 16 | +
|
| 17 | +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png |
| 18 | + :target: https://odoo-community.org/page/development-status |
| 19 | + :alt: Beta |
| 20 | +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png |
| 21 | + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
| 22 | + :alt: License: AGPL-3 |
| 23 | +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github |
| 24 | + :target: https://github.com/OCA/server-tools/tree/16.0/base_field_trigger_warmup |
| 25 | + :alt: OCA/server-tools |
| 26 | +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
| 27 | + :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_field_trigger_warmup |
| 28 | + :alt: Translate me on Weblate |
| 29 | +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png |
| 30 | + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0 |
| 31 | + :alt: Try me on Runboat |
| 32 | + |
| 33 | +|badge1| |badge2| |badge3| |badge4| |badge5| |
| 34 | + |
| 35 | +The ORM resolves the transitive closure of compute triggers lazily: the first |
| 36 | +time a field is written, Odoo walks its ``@api.depends`` graph and caches the |
| 37 | +resulting trigger tree in the registry. On models with many interdependent |
| 38 | +stored computed fields, that first write pays for the whole closure, so the |
| 39 | +first request served by each worker is noticeably slower than the ones that |
| 40 | +follow, and every restart brings the penalty back. |
| 41 | + |
| 42 | +This module builds those trees while the registry loads, where no user is |
| 43 | +waiting. It has no user interface and no effect on behaviour: it only decides |
| 44 | +*when* work the ORM would do anyway is done. |
| 45 | + |
| 46 | +It was extracted from a production deployment whose invoice line model carries |
| 47 | +around 180 interdependent stored fields: the first write on a fresh worker cost |
| 48 | +about five times what every following write cost. Warming up the trees at boot |
| 49 | +removed the difference. |
| 50 | + |
| 51 | +**Table of contents** |
| 52 | + |
| 53 | +.. contents:: |
| 54 | + :local: |
| 55 | + |
| 56 | +Configuration |
| 57 | +============= |
| 58 | + |
| 59 | +By default every model in the registry is warmed up. On a large database that |
| 60 | +costs a few seconds of boot time per worker, which is usually a good trade, |
| 61 | +but it can be narrowed down. |
| 62 | + |
| 63 | +To warm up only the models that matter, set the system parameter |
| 64 | +``base_field_trigger_warmup.models`` to a comma separated list of model names:: |
| 65 | + |
| 66 | + base_field_trigger_warmup.models = account.move,account.move.line |
| 67 | + |
| 68 | +Model names that do not exist in the registry are ignored with a warning. |
| 69 | +Setting the parameter to ``*`` or leaving it empty restores the default of |
| 70 | +warming up everything. |
| 71 | + |
| 72 | +To disable the warmup entirely without uninstalling the module, for instance on |
| 73 | +a development machine or in a CI pipeline where boot time matters more than the |
| 74 | +first request, export:: |
| 75 | + |
| 76 | + ODOO_FIELD_TRIGGER_WARMUP=0 |
| 77 | + |
| 78 | +The warmup is always skipped while tests are running. |
| 79 | + |
| 80 | +Usage |
| 81 | +===== |
| 82 | + |
| 83 | +There is nothing to do: installing the module is enough. |
| 84 | + |
| 85 | +At the end of each registry load the module logs, at INFO level, how many |
| 86 | +trigger trees it built and how long it took:: |
| 87 | + |
| 88 | + INFO odoo.addons.base_field_trigger_warmup: Warmed up 24868 field |
| 89 | + trigger trees in 6.52s |
| 90 | + |
| 91 | +Use that line to decide whether the default scope is worth its boot cost, and |
| 92 | +narrow it down with the system parameter described in the configuration section |
| 93 | +if it is not. |
| 94 | + |
| 95 | +Known issues / Roadmap |
| 96 | +====================== |
| 97 | + |
| 98 | +The module relies on ``Registry.get_field_trigger_tree``, which is private ORM |
| 99 | +API. It is called defensively: if a future Odoo version renames or removes it, |
| 100 | +the module logs the fact and does nothing instead of breaking the registry |
| 101 | +load. Porting to a new version should start by checking that method. |
| 102 | + |
| 103 | +Warming up the trees hides the symptom of a wide compute graph. When the first |
| 104 | +request of a worker is slow enough to need this module, it is also worth |
| 105 | +looking at whether the graph itself can be reduced. |
| 106 | + |
| 107 | +Bug Tracker |
| 108 | +=========== |
| 109 | + |
| 110 | +Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. |
| 111 | +In case of trouble, please check there if your issue has already been reported. |
| 112 | +If you spotted it first, help us to smash it by providing a detailed and welcomed |
| 113 | +`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_field_trigger_warmup%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
| 114 | + |
| 115 | +Do not contact contributors directly about support or help with technical issues. |
| 116 | + |
| 117 | +Credits |
| 118 | +======= |
| 119 | + |
| 120 | +Authors |
| 121 | +~~~~~~~ |
| 122 | + |
| 123 | +* KMEE |
| 124 | + |
| 125 | +Contributors |
| 126 | +~~~~~~~~~~~~ |
| 127 | + |
| 128 | +* `KMEE <https://www.kmee.com.br>`_: |
| 129 | + |
| 130 | + * Luis Felipe Mileo <mileo@kmee.com.br> |
| 131 | + |
| 132 | +Maintainers |
| 133 | +~~~~~~~~~~~ |
| 134 | + |
| 135 | +This module is maintained by the OCA. |
| 136 | + |
| 137 | +.. image:: https://odoo-community.org/logo.png |
| 138 | + :alt: Odoo Community Association |
| 139 | + :target: https://odoo-community.org |
| 140 | + |
| 141 | +OCA, or the Odoo Community Association, is a nonprofit organization whose |
| 142 | +mission is to support the collaborative development of Odoo features and |
| 143 | +promote its widespread use. |
| 144 | + |
| 145 | +This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/16.0/base_field_trigger_warmup>`_ project on GitHub. |
| 146 | + |
| 147 | +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
0 commit comments