CPU usage due to expensive use of lodash.cloneDeep() #1999
meks007
started this conversation in
Feature Request
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
the current implementation of the Websocket wrapper (https://github.com/zachowj/node-red-contrib-home-assistant-websocket/blob/main/src/homeAssistant/Websocket.ts) makes extensive use of lodash.cloneDeep for nearly all returned objects. For areas/devices/floors this might not be an issue, but it's also used for entities and states.
When benchmarking the current implementation using Clinic, the result with regards to CPU usage is devastating.
Around 35% of CPU usage stems from lodash.cloneDeep. And it's totally avoidable and can be reduced dramatically.
I propose a switch from cloneDeep to a native implementation or even shallow copies.
All reactions