diff options
| author | Xavier-Do <xdo@odoo.com> | 2020-02-18 17:08:46 +0000 |
|---|---|---|
| committer | Xavier-Do <xdo@odoo.com> | 2020-02-19 11:15:09 +0000 |
| commit | 7e9918dbe3e42caddbdf4ad8fe41a5124714ba13 (patch) | |
| tree | 1c93c8afb6c553e2c962f3f18097c3840e851222 | |
| parent | 047e222373918c7b7ff1630c62bca6ec6a425132 (diff) | |
[FIX] core: improve get_files performances
On a standard odoo install, `MigrationManager._get_files` represent
more than 4% of an install. This is because the legacy
odoo/base/maintenance/migration path was added to upgrade.__path__
once by module, making the get_filed check 574^2 os.path.exists.
This commit adds a check on initialize_sys_path to call it only once,
and merge legacy path with upgrade-path management in order to benefit
of the `up not in upgrade.__path__` check. This second part of the fix
will also remove the local dir from the upgrades paths.
A further improvement would be to fix MigrationManager in order to skip
_get_file work on a fresh install, (wip by rco-odoo)
closes odoo/odoo#45699
X-original-commit: 497330a695ed52a33f9c9b9c27b149446de0db29
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
| -rw-r--r-- | odoo/modules/module.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 508d138ee7a..f9f11525850 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -32,6 +32,9 @@ def initialize_sys_path(): Setup the addons path ``odoo.addons.__path__`` with various defaults and explicit directories. """ + if getattr(initialize_sys_path, 'called', False): # only initialize once + return + initialize_sys_path.called = True # hook odoo.addons on data dir dd = os.path.normcase(tools.config.addons_data_dir) @@ -51,16 +54,12 @@ def initialize_sys_path(): # hook odoo.upgrade on upgrade-path from odoo import upgrade - for up in tools.config['upgrade_path'].split(','): + legacy_upgrade_path = os.path.join(base_path, 'base', 'maintenance', 'migrations') + for up in (tools.config['upgrade_path'] or legacy_upgrade_path).split(','): up = os.path.normcase(os.path.abspath(tools.ustr(up.strip()))) if up not in upgrade.__path__: upgrade.__path__.append(up) - # hook odoo.upgrade on legacy odoo/addons/base/maintenance/migrations symlink - if not tools.config['upgrade_path']: - upgrade.__path__.append(os.path.join( - base_path, 'base', 'maintenance', 'migrations')) - # create decrecated module alias from odoo.addons.base.maintenance.migrations to odoo.upgrade spec = importlib.machinery.ModuleSpec("odoo.addons.base.maintenance", None, is_package=True) maintenance_pkg = importlib.util.module_from_spec(spec) |
