[ 
https://issues.apache.org/jira/browse/KAFKA-1351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15584156#comment-15584156
 ] 

Nacho Solis commented on KAFKA-1351:
------------------------------------

Thanks [~jjkoshy].

Yes, this is a pet peeve of mine.  Logging can be slow for many reasons.  Not 
only is string formatting a performance hog; but even with lazy evaluation 
things will still take while when you use derived values.

The newer versions of Scala provide a good alternative for this, macros.   
Coming from the C world I always find it surprising when the language (or 
pre-compiler) doesn't provide that type of functionality.  Granted, it can make 
the code hard to follow if used incorrectly, but it can greatly simplify the 
code while still giving you the desired effect.

We could write our own macro-logging layer or we can use something already out 
there like [scala-logging|https://github.com/typesafehub/scala-logging] which 
wraps SLF4J.  It requires Scala 2.11 or higher.

> String.format is very expensive in Scala
> ----------------------------------------
>
>                 Key: KAFKA-1351
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1351
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 0.7.2, 0.8.0, 0.8.1
>            Reporter: Neha Narkhede
>              Labels: newbie
>         Attachments: KAFKA-1351.patch, KAFKA-1351_2014-04-07_18:02:18.patch, 
> KAFKA-1351_2014-04-09_15:40:11.patch
>
>
> As found in KAFKA-1350, logging is causing significant overhead in the 
> performance of a Kafka server. There are several info statements that use 
> String.format which is particularly expensive. We should investigate adding 
> our own version of String.format that merely uses string concatenation under 
> the covers.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to