Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B5CF18312 for ; Mon, 18 Apr 2016 11:18:29 +0000 (UTC) Received: (qmail 17680 invoked by uid 500); 18 Apr 2016 11:18:29 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 17623 invoked by uid 500); 18 Apr 2016 11:18:28 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 17613 invoked by uid 99); 18 Apr 2016 11:18:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Apr 2016 11:18:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id E52101A0414 for ; Mon, 18 Apr 2016 11:18:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.28 X-Spam-Level: * X-Spam-Status: No, score=1.28 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=magine-com.20150623.gappssmtp.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 7r0gI2s2QFUf for ; Mon, 18 Apr 2016 11:18:24 +0000 (UTC) Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 846965F65A for ; Mon, 18 Apr 2016 11:18:24 +0000 (UTC) Received: by mail-oi0-f53.google.com with SMTP id x201so21175944oif.3 for ; Mon, 18 Apr 2016 04:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=magine-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=2nyoj3al56D24Aq1pJviSQQGzMObX0yVVYnD35f7nmg=; b=aoaFnlS71ZZ5DV6MHQHOsnHu5dpCz/dNss8CwNcASyoZBZLtMN6CtgQEyxRpCS1VVI I/Cx9lVwcg4oIRZgKS9GXOPOkml7YND1a5kPUXiKW3NcyqPq952RPAvRuu4x7Scq+ZUj nYl6FOUDU5Vw3TNjhCQ+YiwuFT0IT9rvDEEt1dQJckUwZLOXyS2EhK53AZl7qGAn5kQ5 YKXjAIFGKkffJLXx8qCVBL0ShTCz9jxBNaojVnI2lK5RKe+v8lyVwN01qZ5ZUZs7SFYW k/MDz8Opgqw7lGs/r/Ac4xpPkzDaONwcM6lSeo/NatTQOg8pfyQIcIBa5eKXGk3ouZJf r8mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=2nyoj3al56D24Aq1pJviSQQGzMObX0yVVYnD35f7nmg=; b=EQujYrAgRXvChWrGrEYqU2Wf/F16TIYDu1HIhCxltsBptsHtu0EkcNFqP+ddZ6ZWl0 z33TFdoFpnuzZJilu2XnisTHf8/z5Qatfnr3qdI6B63Gm+zPkU4JYiLJ7odXA2lAF5pS D5IppQQ9bkLcXHPrvqJFfJ8yZDb3oMq2kdV+veyAvD2CJDDejwalA9NTknzBkhVzPjuD p+hMhi7YhkZ2PEgYSaF6mZWTqCY1SnhishEpVD7DB9845BSFcGiJ12hMAXtdCUAQ5vvH ZZ/0Q5XNVA//4Oe870Wiw+PwLBjbkIveZiJrF0fmFxU99mqx9FNjEFXcSPh5BQgIIpC9 La3Q== X-Gm-Message-State: AOPr4FWZ+1PriSeV5DMpZE509CPQDsHyaG/JZri1ElFS0Tq41C83j3J1Vxn4EcMUikuN5QXuSzMIlrPJgK0dVg0q MIME-Version: 1.0 X-Received: by 10.157.3.143 with SMTP id f15mr5653381otf.25.1460978303124; Mon, 18 Apr 2016 04:18:23 -0700 (PDT) Received: by 10.157.39.13 with HTTP; Mon, 18 Apr 2016 04:18:22 -0700 (PDT) In-Reply-To: References: Date: Mon, 18 Apr 2016 13:18:22 +0200 Message-ID: Subject: Re: [jira] [Commented] (LOG4J2-1297) Document "gc-free" configuration and performance From: =?UTF-8?Q?Mikael_St=C3=A5ldal?= To: Log4J Developers List Content-Type: multipart/alternative; boundary=94eb2c03b022c85e540530c08490 --94eb2c03b022c85e540530c08490 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Will garbage-free logging be enabled or disabled by default? On Mon, Apr 18, 2016 at 2:58 AM, Remko Popma (JIRA) wrote= : > > [ > https://issues.apache.org/jira/browse/LOG4J2-1297?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1524501= 8#comment-15245018 > ] > > Remko Popma commented on LOG4J2-1297: > ------------------------------------- > > TODO allocate many temporary objects -> allocate temporary objects > > TODO multi-threaded applications that use synchronous logging may see > worse performance: the lock that was previously only around the IO > operation is widened to include the text formatting and conversion to > bytes. -> _synchronous_ logging performance may be worse for multi-thread= ed > applications in this mode due to synchronization on the shared buffer. If > your application is multi-threaded and logging performance is important, > consider using Async Loggers. > > TODO Caution: Only dates in the predefined formats are garbage-free -> > Caution: Only the predefined date formats are garbage-free > > TODO "(Note that Log4j may call toString() on message and parameter > objects when garbage-free logging is disabled because system property > log4j2.enable.threadlocals is set to "false".)" -> Log4j may call > toString() on message and parameter objects when garbage-free logging is > disabled (when system property log4j2.enable.threadlocals is set to > "false".) > > TODO "made an effort to make logging code garbage-free" -> "made an effor= t > to make logging garbage-free" > > > > Document "gc-free" configuration and performance > > ------------------------------------------------ > > > > Key: LOG4J2-1297 > > URL: https://issues.apache.org/jira/browse/LOG4J2-1297 > > Project: Log4j 2 > > Issue Type: New Feature > > Components: Documentation > > Affects Versions: 2.5 > > Reporter: Remko Popma > > Assignee: Remko Popma > > Fix For: 2.6 > > > > Attachments: log4j-2.5-FlightRecording.png, > log4j-2.6-FlightRecording.png > > > > > > Update the site with a description of which configurations are GC-free > (i.e., that don't create temporary objects in steady running state). > > Currently that means > > * Loggers are all asynchronous (Log4jContextSelector is set to > org.apache.logging.log4j.core.async.AsyncLoggerContextSelector). > > * The configuration does not contain a section. > > * The "steady-state" appenders are either RandomAccessFile or > RollingRandomAccessFile Appenders (logging to any other appender will cau= se > temporary objects to be created - including ConsoleAppender). > > * The Layout is a PatternLayout that uses one of the pre-defined date > formats, does not have any regular expression replacements, and does not > have lookups (TODO: may need to restrict this further). > > * The thread name is cached (this is the [default| > https://issues.apache.org/jira/browse/LOG4J2-467]). Running with > -DAsyncLogger.ThreadNameStrategy=3DUNCACHED will create garbage. > > * In user code, when logging a parameterized message, the number of > parameters is no more than ... (TBD pending discussion in LOG4J2-1278). > > * In user code, when logging a parameterized message, parameters of > primitive type are boxed in a reused StringBuilder (Log4j provides a > utility to make this relatively painless). > > Even with the above restrictions, Log4j may occasionally create garbage= : > > * Initially StringBuilders are presized to 128 characters. They may gro= w > for larger messages (contributing to garbage in Old Gen). If the > StringBuilder grows beyond 512 characters it is trimmed back to 512 > characters to prevent memory leaks from excessively long messages. (TODO: > the resizing algorithm is {{size =3D value.length * 2 + 2}}, so a better > cutoff value is 518.) > > * Messages containing {{"$\{"}} will be converted to a String and > StrSubstitutor will be used to replace occurences of variables with their > matching values. Multiple temporary objects are created during this proce= ss. > > Furthermore, we need to explain that some of this functionality depends > on ThreadLocals and so is disabled by default in web applications to > prevent memory leaks. The page should also explain how to manually switch > off the use of ThreadLocals. > > Finally, the page should show a performance test comparison similar to > the [performance section| > http://logging.apache.org/log4j/2.x/manual/async.html#Performance] on the > Async Loggers page. I'm thinking a comparison between Logback, Log4j-1, > Log4j-2.0, Log4j-2.6 "classic" and Log4j-2.6 "gc-free" would be ideal. > > > > -- > This message was sent by Atlassian JIRA > (v6.3.4#6332) > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-dev-help@logging.apache.org > > --=20 [image: MagineTV] *Mikael St=C3=A5ldal* Senior software developer *Magine TV* mikael.staldal@magine.com Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. --94eb2c03b022c85e540530c08490 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Will garbage-free logging be enabled or disabled by defaul= t?

On Mon, A= pr 18, 2016 at 2:58 AM, Remko Popma (JIRA) <jira@apache.org> w= rote:

=C2=A0 =C2=A0 [ https://issues.apache.org/jira/browse/LOG4J2-1297?page=3Dcom.at= lassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedComme= ntId=3D15245018#comment-15245018 ]

Remko Popma commented on LOG4J2-1297:
-------------------------------------

TODO allocate many temporary objects -> allocate temporary object= s

TODO multi-threaded applications that use synchronous logging may see worse= performance: the lock that was previously only around the IO operation is = widened to include the text formatting and conversion to bytes. -> _sync= hronous_ logging performance may be worse for multi-threaded applications i= n this mode due to synchronization on the shared buffer. If your applicatio= n is multi-threaded and logging performance is important, consider using As= ync Loggers.

TODO Caution: Only dates in the predefined formats are garbage-free -> C= aution: Only the predefined date formats are garbage-free

TODO "(Note that Log4j may call toString() on message and parameter ob= jects when garbage-free logging is disabled because system property log4j2.= enable.threadlocals is set to "false".)" -> Log4j may cal= l toString() on message and parameter objects when garbage-free logging is = disabled (when system property log4j2.enable.threadlocals is set to "f= alse".)

TODO "made an effort to make logging code garbage-free" -> &qu= ot;made an effort to make logging garbage-free"


> Document "gc-free" configuration and performance
> ------------------------------------------------
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Key: LOG4= J2-1297
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0URL: https://issues.apache.org/jira/browse/LOG4J2-1297 >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Project: Log4j 2
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Issue Type: New Feature
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Components: Documentation
>=C2=A0 =C2=A0 Affects Versions: 2.5
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Reporter: Remko Popma
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Assignee: Remko Popma
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Fix For: 2.6
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Attachments: log4j-2.5-FlightRecordin= g.png, log4j-2.6-FlightRecording.png
>
>
> Update the site with a description of which configurations are GC-free= (i.e., that don't create temporary objects in steady running state). > Currently that means
> * Loggers are all asynchronous (Log4jContextSelector is set to org.apa= che.logging.log4j.core.async.AsyncLoggerContextSelector).
> * The configuration does not contain a <Properties> section.
> * The "steady-state" appenders are either RandomAccessFile o= r RollingRandomAccessFile Appenders (logging to any other appender will cau= se temporary objects to be created - including ConsoleAppender).
> * The Layout is a PatternLayout that uses one of the pre-defined date = formats, does not have any regular expression replacements, and does not ha= ve lookups (TODO: may need to restrict this further).
> * The thread name is cached (this is the [default|https://issues.apache.org/jira/browse/LOG4J2-467]). Running with -D= AsyncLogger.ThreadNameStrategy=3DUNCACHED will create garbage.
> * In user code, when logging a parameterized message, the number of pa= rameters is no more than ... (TBD pending discussion in LOG4J2-1278).
> * In user code, when logging a parameterized message, parameters of pr= imitive type are boxed in a reused StringBuilder (Log4j provides a utility = to make this relatively painless).
> Even with the above restrictions, Log4j may occasionally create garbag= e:
> * Initially StringBuilders are presized to 128 characters. They may gr= ow for larger messages (contributing to garbage in Old Gen). If=C2=A0 the S= tringBuilder grows beyond 512 characters it is trimmed back to 512 characte= rs to prevent memory leaks from excessively long messages. (TODO: the resiz= ing algorithm is {{size =3D value.length * 2 + 2}}, so a better cutoff valu= e is 518.)
> * Messages containing {{"$\{"}} will be converted to a Strin= g and StrSubstitutor will be used to replace occurences of variables with t= heir matching values. Multiple temporary objects are created during this pr= ocess.
> Furthermore, we need to explain that some of this functionality depend= s on ThreadLocals and so is disabled by default in web applications to prev= ent memory leaks. The page should also explain how to manually switch off t= he use of ThreadLocals.
> Finally, the page should show a performance test comparison similar to= the [performance section|http://lo= gging.apache.org/log4j/2.x/manual/async.html#Performance] on the Async = Loggers page. I'm thinking a comparison between Logback, Log4j-1, Log4j= -2.0, Log4j-2.6 "classic" and Log4j-2.6 "gc-free" would= be ideal.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org




--
=
3D"MagineTV"

Mikael St=C3=A5ldal
Senior software developer

Magine TV
mikael.s= taldal@magine.com=C2=A0 =C2=A0=C2=A0
Grev Turegatan 3 =C2=A0|=C2=A0114 46 St= ockholm, Sweden=C2=A0 | =C2=A0 www.magine.com

Privilege= d and/or Confidential Information may be contained in this message. If=20 you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,=C2=A0
you should destroy this message and kindly notify the sender by reply ema= il. =C2=A0=C2=A0
--94eb2c03b022c85e540530c08490--