Updated post…
What I meant with “log execution time” is this code in every rule’s triggered function:
def _on_event(self, event = None):
info(LOG, self.rule_name + " triggered by " + str(event))
start_time = time.time()
self.on_event(event) # do the actual work
info(LOG, self.rule_name + " finished after a processing time {:.1f} s", time.time()-start_time)
The log output shows the named <0.01s processing time initially. It is going up to several seconds after 5 minutes (see below). I have made sure self.on_event()
is not blocking for any rule by checking the pairing of the log outputs above.
I have added some thread monitoring showing all threads of the HABApp process - one during expected operation, and one one minute later when the system is throttled completely:
Report
The system is running as expected for around 5 minutes. During this time, the per rule execution time is mostly below 0.01s with some smaller (and expected) exceptions. ps
is showing HABApp with 1 to 3% processor time and here is a thread report at this time:
Thread ID: 884201 | Name: MainThread | User Time: 4.79s | System Time: 0.43s
Thread ID: 884203 | Name: Thread-1 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884204 | Name: HABApp_LogBufferEven | User Time: 0.11s | System Time: 0.01s
Thread ID: 884205 | Name: Thread-3 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884206 | Name: Thread-2 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884207 | Name: Thread-5 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884208 | Name: Thread-4 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884209 | Name: Thread-7 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884210 | Name: Thread-6 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884211 | Name: Thread-9 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884212 | Name: Thread-8 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884213 | Name: asyncio_0 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884224 | Name: HabAppWorker_0 | User Time: 1.14s | System Time: 0.04s
Thread ID: 884233 | Name: HabAppWorker_1 | User Time: 0.36s | System Time: 0.01s
Thread ID: 884236 | Name: HabAppWorker_2 | User Time: 0.08s | System Time: 0.01s
Thread ID: 884237 | Name: HabAppWorker_3 | User Time: 0.06s | System Time: 0.01s
Thread ID: 884278 | Name: HabAppWorker_4 | User Time: 0.09s | System Time: 0.02s
Thread ID: 884279 | Name: HabAppWorker_5 | User Time: 0.05s | System Time: 0.01s
Thread ID: 884280 | Name: HabAppWorker_6 | User Time: 0.09s | System Time: 0.01s
Thread ID: 884281 | Name: HabAppWorker_7 | User Time: 0.05s | System Time: 0.02s
Thread ID: 884282 | Name: HabAppWorker_8 | User Time: 0.04s | System Time: 0.01s
Thread ID: 884349 | Name: HabAppWorker_9 | User Time: 0.05s | System Time: 0.01s
Thread ID: 884795 | Name: Thread-10 | User Time: 0.00s | System Time: 0.00s
Then, after these 5 minutes, HAPApp is going to 100% within a second and stays there. Worker thread HabAppWorker_10
start to show a lot of user time / processing.
Thread ID: 884201 | Name: MainThread | User Time: 5.94s | System Time: 0.63s
Thread ID: 884203 | Name: Thread-1 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884204 | Name: HABApp_LogBufferEven | User Time: 0.17s | System Time: 0.04s
Thread ID: 884205 | Name: Thread-3 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884206 | Name: Thread-2 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884207 | Name: Thread-5 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884208 | Name: Thread-4 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884209 | Name: Thread-7 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884210 | Name: Thread-6 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884211 | Name: Thread-9 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884212 | Name: Thread-8 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884213 | Name: asyncio_0 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884224 | Name: HabAppWorker_0 | User Time: 1.18s | System Time: 0.04s
Thread ID: 884233 | Name: HabAppWorker_1 | User Time: 0.39s | System Time: 0.02s
Thread ID: 884236 | Name: HabAppWorker_2 | User Time: 0.11s | System Time: 0.03s
Thread ID: 884237 | Name: HabAppWorker_3 | User Time: 0.09s | System Time: 0.02s
Thread ID: 884278 | Name: HabAppWorker_4 | User Time: 0.11s | System Time: 0.03s
Thread ID: 884279 | Name: HabAppWorker_5 | User Time: 0.07s | System Time: 0.02s
Thread ID: 884280 | Name: HabAppWorker_6 | User Time: 0.12s | System Time: 0.01s
Thread ID: 884281 | Name: HabAppWorker_7 | User Time: 0.08s | System Time: 0.03s
Thread ID: 884282 | Name: HabAppWorker_8 | User Time: 0.16s | System Time: 0.02s
Thread ID: 884349 | Name: HabAppWorker_9 | User Time: 0.09s | System Time: 0.02s
Thread ID: 884795 | Name: Thread-10 | User Time: 0.00s | System Time: 0.00s
Thread ID: 884940 | Name: HabAppWorker_10 | User Time: 59.28s | System Time: 0.06s
Thread ID: 884941 | Name: HabAppWorker_11 | User Time: 0.02s | System Time: 0.01s
Thread ID: 884942 | Name: HabAppWorker_12 | User Time: 0.02s | System Time: 0.00s
Thread ID: 885080 | Name: HabAppWorker_13 | User Time: 0.01s | System Time: 0.00s
Thread ID: 885081 | Name: HabAppWorker_14 | User Time: 0.02s | System Time: 0.00s
Thread ID: 885082 | Name: HabAppWorker_15 | User Time: 0.01s | System Time: 0.00s
The odd thing is although I have instrumented all Rule triggered functions with output on user_time
and active thread id, none of them seems to run on HabAppWorker_10
. No rule uses excessive user_time at all, everything below 0.05s.
Is there anything except rules using the HABApp worker threads?
I will start to work with a Python profiler next, but any idea how to troubleshoot that is appreciated.