-
Notifications
You must be signed in to change notification settings - Fork 192
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
Faster import part2: Delay import of heavy packages #6106
Conversation
9cba5f7
to
220b2cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sphuber this is ready for review
@@ -9,11 +9,12 @@ | |||
########################################################################### | |||
# pylint: disable=cyclic-import | |||
"""AiiDA manager for global settings""" | |||
import asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: About half of the cost of importing plumpy (30ms) comes from importing asyncio
@@ -9,8 +9,6 @@ | |||
|
|||
LOGGER = logging.getLogger(__name__) | |||
|
|||
__all__ = ('ProcessLauncher',) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: This is a breaking API change in principle, but since this only seems to be used in aiida/manage/manager.py
I think it is okay. This is AFAIK the only way how to avoid importing plumpy
upon every import, since the ProcessLauncher
uses plumpy.ProcessLauncher
as a parent class.
Thanks @danielhollas . The changes look good to me. You are right that the removal of the export of |
Thanks @sphuber ! I have more lined up, specifically targeting verdi. |
for more information, see https://pre-commit.ci
544b25e
to
8dc546f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @danielhollas
Delay import of
disk_objectstore
,jsonschema
,requests
,plumpy
andparamiko
. Obviously, many of these will be eventually imported for many tasks, but right now they are imported indiscriminately for everything, making everything slower, see benchmarks below.There are other avenues for improvement, but I wanted to get the most impactful stuff first.
Timings against the main branch
import aiida
import aiida.orm
import aiida.cmdline.commands