CabbageDevelopment / qasync

Python library for using asyncio in Qt-based applications.
BSD 2-Clause "Simplified" License
334 stars 45 forks source link

Reduce logging overhead #41

Closed internetimagery closed 3 years ago

internetimagery commented 3 years ago

I noticed in some cases with a lot of async functions flying around, this logging overhead can become quite dramatic. In the worst case I had a task taking 60 seconds drop to 15 after killing all the logging (as in removing the lines, not just disabling the logger). So I've tackled this in two ways.

  1. Using pythons lazy logging. So that if there is no handler picking up the debug messages, we have no string formatting overhead.
  2. Tying the debug logging in the event loop to the built in "(set|get)_debug" state. So even with debug logging enabled, the messages from the event loop can selectively be enabled/disabled.
TheGreatCabbage commented 3 years ago

Nice work, thanks for the contribution!