Why would blocking=False be slower? #306
-
I have this blocking code which works well already, but I was curious about the non-blocking mode
So I tried to convert it to non-blocking to see what happens
But it seems the speed is significantly slower. Am I doing something I am not supposed to do? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
When you use In fact, before the daemon mode was implemented in #111 (and later became the default in version 1.x), all function calls invoked a new AutoHotkey process! In PR #111 I also noted the significant performance difference in these operating models:
Something like a 25x difference! And since then we've also made significant performance improvements (700%+ in some cases!) in the daemon since then, so the daemon is even faster now. So, for performance sake alone, you're usually better off not using Using |
Beta Was this translation helpful? Give feedback.
When you use
blocking=False
, a new AutoHotkey subprocess is spawned to facilitate this. It takes some time for Windows to start the process as well as for the AutoHotkey interpreter to start and run the script. In tight loops, this can account for a significant slowdown.In fact, before the daemon mode was implemented in #111 (and later became the default in version 1.x), all function calls invoked a new AutoHotkey process! In PR #111 I also noted the significant performance difference in these operating models: