rotki / rotki

A portfolio tracking, analytics, accounting and management application that protects your privacy
https://rotki.com
GNU Affero General Public License v3.0
2.83k stars 522 forks source link

Logging performance improvement via lazy string interpolation and more #2912

Open LefterisJP opened 3 years ago

LefterisJP commented 3 years ago

Abstract

After https://github.com/rotki/rotki/pull/2911 we removed the LogAnonymizing adapter's functionality but kept it as an empty adapter since it's used in many places and its use is what actually allows keyword arguments.

Keyword arguments, while useful, along with fstrings share the same problem. That the arguments are evaluated even if logging is disabled and not emitted.

The way to handle this correctly is to log using the method showcased here.

Additionally as per the log optimization docs we can also add an logger.isEnabledFor(logging.DEBUG) call before each big logging call if passing the arguments themselves ends up being expensive.

Task

LefterisJP commented 2 years ago

We should probably have some performance tests to see if makign the above changes would indeed improve logging performance.