cobalt icon indicating copy to clipboard operation
cobalt copied to clipboard

Use lazy logging for non-constant strings

Open MrBergin opened this issue 4 years ago • 2 comments

There's places in Cobalt (e.g. BaseProperty.onChange) that would benefit from switching to their lazy logging counterparts, e.g:

logger.debug("Subscribing to changes to property: $this.")

Should be

logger.debug { "Subscribing to changes to property: $this." }

I can't speak for the JVM implementation of uuid, but when looking at performance in the browser for Zircon I could see a fair chunk of time spent in uuid.toString() and garbage collecting strings which went away when using lazy logging and turning debug off.

MrBergin avatar Apr 23 '20 23:04 MrBergin

Thanks, @MrBergin this is a great observation! I'm gonna ad this to the next release.

adam-arold avatar May 02 '20 19:05 adam-arold

I just grepped for log\w+\.\w+\( in the whole project and there are only some logger.warn() calls left, so this issue seems to be fixed. Especially the aforementioned call(s) in BaseProperty are already changed.

Baret avatar Mar 31 '21 08:03 Baret