-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat: Load converters on-demand #8471
base: master
Are you sure you want to change the base?
Conversation
@sjorge @kirovilya if you have some time, and can review the changes, mostly just the core logic changes in |
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.
I only looked at index.ts, this code has always been a bit confusing at times IMHO.
I think this look good, I left a few nits feel free to ignore them but It could slightly improve readability I think.
Two questions/ideas did pop into my head while reading over this...
- Can definitions loaded from external providers somehow be marked on the Device, the frontend for example could then maybe somehow display that. This could be helpful when people forgot to remove one if changes get merged or just to know which devices are currently dependent on external converters.
- The logger change reminded again we have some quirks for certain vendors/devices. I wonder if we can somehow get these out of index.ts, perhaps there could be some sort of hook that can be used instead so we can keep these in their respective vendor files.
@kirovilya could you also take a look at this? |
e76a1c9
to
7b11ecd
Compare
@sjorge Thanks for the feedback 👍
|
7b11ecd
to
543274d
Compare
543274d
to
5eb45c2
Compare
This is intended for post-2.0.0.
Will keep all conflict-prone changes to a minimum until ready to execute all scripts to update the entire repo.
Changes
Logic before
zigbeeModel
to array of definitions)Definition resolving
zigbeeModel
Device
Logic after
zigbeeModel
to array of [module
,definition index
]) into memory on start (index is JSON built at compile time)Definition resolving
zigbeeModel
index
Device
Other changes
DIFF
src/devices/*
using named exportsgenerateDefinition.ts
to avoid clash with globals.TODO:
resolveDefinition
in Z2M (optimize as needed)Benchmarks
This being a deep change in the architecture, some in-depth testing was required. Since this is mostly about memory, tests mostly focus on memory...
Tested using Zigbee2MQTT 2.0.0 (for both "Before" & "After").
I tried to minimize the impact of other systems while testing, but allow for some margin of error still...
VSCode Profiler
With brand new network (already established on coordinator, no device).
Cold start.
Heap snapshot once settled after start (limited to items above 1 MB in "Before"):
Clinic.js
With brand new network (already established on coordinator).
Cold start and pairing of 1 device.
Red=Before
Blue=After
Even Loop use
Event Loop delay
Overall, I'd say we can expect memory usage to be around 60% of what it was before. This is reflected throughout the application's runtime, and should remain pretty stable, with small spikes only expected around the addition of new devices (i.e. need to load some converters).