fpillet / NSLogger

A modern, flexible logging tool
Other
5k stars 573 forks source link

NSLogger can slow down internet connection #297

Open Tibbs opened 3 years ago

Tibbs commented 3 years ago

I have been using NSLogger for a very long time and I find it extremely useful. Having said that, about two years ago I started receiving emails from my users that my Mac apps slowed down their internet connection. At first, I dismissed it as it didn't make sense but some users sent me screen recordings showing just that: when my app was running the internet download speed was significantly lower. I identified that NSLogger can cause this slowdown. I was able to reproduce similar results, but it not consistent. For example, switching to another wifi network or restarting the computer can relieve the issue temporarily. When in "slowdown mode" opening an app that has NSLogger or the NSLogger console can slow down my internet from about 20% to more than 50% tests after tests Any thoughts?

fpillet commented 3 years ago

The main question you have to ask yourself is, why are you shipping a production app with logs enabled?

NSLogger logs are as efficient as possible but have never meant to be enabled all the time. There is a definite overhead, especially if the logger is connected to a log viewer. Besides, we are using low-level CFStream networking and this ought to be replaced after a Swift rewrite to use a different API because this one is not going to give optimal results now that the OS has changed so much.

Tibbs commented 3 years ago

@fpillet Thank you for your quick response and explanation. The problem is the release macro for NSLog() is LogMessageCompat() which enables NSLogger. If I remove that macro it doesn't create the connection.