You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance: ~10 object reads and ~4 state writes per incoming Zigbee message #3037
I measured how many object/state calls the adapter makes per incoming Zigbee message, to find out where a lean improvement is possible without new caches or extra memory.
Setup
GitHub master (3.6.0-dev, incl. fix/numeric-presets), ZStack over LAN, 42 devices (mostly lights and plugs), 8 groups. The adapter methods (getObjectAsync, setState, …) were wrapped with counters, and every event/msg from the zigbee controller was counted. Measuring branch only, not meant for a PR: https://github.com/Schimi1983/ioBroker.zigbee/tree/measure/m0-4
Result (35 min, 232 messages)
Phase
getObjectAsync
setState
other
normal operation (min 5–35, 178 messages)
9.9 per message
4.15 per message
getState / getForeignObject / extendObject ≈ 0
adapter start (first ~5 min)
≈ 4,400 in total (≈ 100 per device)
–
90× extendObjectAsync, 86× getForeignObjectAsync
Availability pings are included, so the per-message values are slightly too high.
Where the reads come from (lib/statescontroller.js)
updateState() is called for every value of a message (typically value(s) + linkquality + available + msg_from_zigbee) and reads two objects each time: getObjectAsync(devId) and getObjectAsync(stateId)
→ 1 + 2 × ~4 ≈ 9–10 reads per message, which matches the measurement
the device object in updateState() is only used for if (devObj); if the state object exists, the device exists as well
msg_from_zigbee is written for every message, also when nobody uses it
Proposal (small steps, no new data structures, no behaviour change by default)
updateState(): read the device object only if the state object does not exist → saves ~4 reads per message (≈ 40 %).
msg_from_zigbee: optional setting "write raw message to msg_from_zigbee" – default on (= current behaviour), so nothing changes for existing users; switching it off saves 1 write + 2 reads per message.
Start: check whether the ≈ 100 object reads per device during start can be reduced (e.g. read the device object once per device in syncDevStates) – I'd look into this only after 1 and 2.
I would prepare 1 as a small PR first and measure again with the same branch. Would that be OK for you, or do you prefer a different approach?
Follow-up with step 1 applied (branch perf/update-state-reads: updateState() reads the device object only when the state object is missing), measured the same way on the same installation:
before
with step 1
change
getObjectAsync per message (normal operation, min 5–35)
9.9
5.7
−42 %
setState per message
4.15
4.10
–
getObjectAsync during adapter start (first 5 min)
≈ 4,870
≈ 1,710
−65 %
189 messages in the compared window (before: 178). No errors or warnings in the log, all devices reachable.
The remaining reads are one per written value in updateState(). Removing them would need a cache of the state objects, which we want to avoid, or dropping msg_from_zigbee, which is the source for "last seen" (see feat: optional last_seen state per device #3051).
So I consider this done and close the issue. Thanks!
The remaining reads are one per written value in updateState(). Removing them would need a cache of the state objects, which we want to avoid, or dropping msg_from_zigbee, which is the source for "last seen" (see feat: optional last_seen state per device #3051).
So I consider this done and close the issue. Thanks!
Activity
Schimi1983 commentedon Nov 15, 2026
Follow-up with step 1 applied (branch
perf/update-state-reads:updateState()reads the device object only when the state object is missing), measured the same way on the same installation:getObjectAsyncper message (normal operation, min 5–35)setStateper messagegetObjectAsyncduring adapter start (first 5 min)189 messages in the compared window (before: 178). No errors or warnings in the log, all devices reachable.
The fix itself is a one-line move plus a comment: master...Schimi1983:ioBroker.zigbee:perf/update-state-reads
If that's fine for you, I'll open it as a PR once one of my two open PRs is through.
Merge pull request #3042 from Schimi1983/perf/update-state-reads
Schimi1983 commentedon Nov 18, 2026
Short wrap-up:
updateState(). Removing them would need a cache of the state objects, which we want to avoid, or droppingmsg_from_zigbee, which is the source for "last seen" (see feat: optional last_seen state per device #3051).So I consider this done and close the issue. Thanks!
Schimi1983 commentedon Nov 20, 2026
Short wrap-up:
updateState(). Removing them would need a cache of the state objects, which we want to avoid, or droppingmsg_from_zigbee, which is the source for "last seen" (see feat: optional last_seen state per device #3051).So I consider this done and close the issue. Thanks!