-
Notifications
You must be signed in to change notification settings - Fork 7
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
Improve support wheel building and speed up IOTile tool #645
Conversation
Moves to a faster alternative entrypoints package and refactors all remaining uses of pkg_resources in iotile-core to use the new ComponentRegistry based system.
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.
LGTM
We might eventually want to standardize the way we use sys.version_info
. Doesn't seem to be a dominant pattern in coretools, https://github.com/iotile/coretools/search?q=sys.version_info&unscoped_q=sys.version_info
@mattrunchey Agreed. My general philosophy has been to avoid it whenever possible and rely on the I did import profiling using import_profiler and found that just importing Ideally, we would just blacklist I'm making an issue for this. |
Opened #647 to track the |
There are four main effects of this PR:
The process by which support wheels are built in
iotile-build
is extended to support more complicated packages that contain many files. Previously, it was assumed that there would only be a few python modules in a support wheel that were just directly copied and bundled together as part of the build process. However, this did not allow for those modules to import other modules reliably since theload_extensions()
method of importing the modules during development would not create a proper package structure to allow for relative imports.As support packages get more complicated because they include tile emulators, it's become important to allow for multiple modules that import each other so the python code in the support packages can be more easily maintained. To this end, an IOTile component can now declare a
support_package
product that is a normal python package. This package will become the support wheel and when individual entry points inside of it are loaded during development they will be loaded as proper submodules so that they can import each other as you would expect.This makes complex support packages inside of a component much easier to design and test since they are just standard python packages. Importantly, they are always imported using their fully unique support distribution name, even during development so that there are not collisions if multiple development components all put their support packages in the
python/support
directories (causing module shadowing on thesupport
global package name).It incrementally enhances
iotile-emulate
to allow for returning hardware versions and improvesSerializableState
to allow for serializing more complicated state trees without needing to specify explicit serializers and deserializers. There is now support for serializing lists and dicts of objects automatically.It removes all explicit references to pkg_resources from
iotile-core
andiotile-build
, moving them both to using faster alternatives (theentrypoints
package for entry points). This is done primarily to allow for faster startup times in the iotile tool, which is quite slow on machines with slow disks such as those with SD cards. See Consider migrating to importlib_resources for finding data file in packages #644 and Add ability to freeze list of iotile plugins #472. As part of this process the IOTile tool loading process was profiled and key culprits that are particularly slow to import (~ 100 ms each) are deferred. This waspast.builtins
andwebsockets
. Neither was required to be loaded eagerly. In testing, these changes were able to speed up the iotile tool's startup time by more than 2x.It adds experimental support for speeding up the
iotile
tool in embedded contexts where the list of installed plugins is static. In that scenario, there is no need to enumerate all installed packages looking for plugins since the list will not change. You can instead just cache a list of plugins and look at that list instead. Two new routinesiotile registry freeze
andiotile registry unfreeze
are added to cache and remove the cache of plugins, respectively. These methods are not yet ready for primetime use. In particular, the rest of CoreTools needs to move completely off ofpkg_resources
before the cache will work completely.