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
First of all, thank you for dedicating part of your time to aiologger.
Before we can talk about the tests we need to first note that when you log to files you are not fully async, not in comparison with an async write to a network socket, for example.
And that's not a Python matter, it is a Operating System matter. There is still no stable/portable interface to async file I/O on modern Opertating Systems and that's why, when logging to files inside an asyncio application, you are in fact using threads. This is somewaht explained here, on aiologger docs.
Now talking about how the tests were written and what each test is trully measuring. We need to make some observations.
You are comparing an asyncio app with an app that's not async. Looking at both code, the code that measures the time of the loggins on an asyncio app takes into the measuring the time that asyncio itself takes to boot and call your main coroutine. I think that to be fair with both scenarios we should time() only the loop that generates the logs. Doing this you will able to remove from the equation the boot time from asyncio machinery.
Also we should try to equalize both scenarios as much as possible. So we should write the test code both on an asyncio app or both outside an asyncio app. As we know that is impossible to run async code outside asyncio, mayble a better test code could be to log (with and without aiologger) inside the same asyncio app.
About the file logging. Maybe a better comparison could be log to stdout on both test cases (standard logging and aiologger) and even there measuring time maybe a tricky metric. Maybe a better approach could be measure CPU efficiency, that is, how much your CPU was waiting for the log to finish while the code was running? That's where asyncio shines! When you have concurrent code performing I/O operations and python can continue to use the CPU while an I/O operations is still incomplete.
Logging to stdout is where aiologger will give you the best it can.
After My test, I find async aiologger is much slower than sync logging!!!
And, I test with sanic web frame, aiologger is slower again.
If you know why it happen, please tell me the reason.
All test run my MacbookPro M1.
async
sync
The text was updated successfully, but these errors were encountered: