<commit_before><?xml version="1.0"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
  license agreements. See the NOTICE file distributed with this work for additional
  information regarding copyright ownership. The ASF licenses this file to
  You under the Apache License, Version 2.0 (the "License"); you may not use
  this file except in compliance with the License. You may obtain a copy of
  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
  by applicable law or agreed to in writing, software distributed under the
  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
  OF ANY KIND, either express or implied. See the License for the specific
  language governing permissions and limitations under the License. -->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  <properties>
    <title>Garbage-free Steady State Logging</title>
    <author email="<EMAIL>"><NAME></author>
  </properties>
  <body>
    <section name="Garbage-free Steady State Logging">
      <p>
        Different applications have different performance requirements.
        Some only need to worry about throughput, but for many
        the most important performance consideration is latency (response time).
        Users of such applications would consider it a big problem
        if the system becomes unresponsive for more than a few seconds, or even milliseconds in some cases.
        In financial trading for example predictable low latency is so important that it is often considered
        worthwhile to trade off some throughput in return for consistent response time.
      </p>
      <p>
        Garbage collection pauses are a common cause of latency spikes and for many systems
        significant effort is spent on controlling these pauses.
      </p>
      <p>
        Traditionally, logging libraries allocate many temporary objects like log event objects, Strings, byte arrays
        and more during steady state logging.
        This contributes to pressure on the garbage collector and increases the frequency with which GC pauses occur.
        From version 2.6, Log4j can be run in a "garbage free" mode where objects and buffers are reused
        and temporary object allocation is avoided as much as possible.
      </p>
      <p>

      </p>
      <a name="jfr" />
      <subsection name="A Contrived Example">
        <p>
          To highlight the difference, we used Java Flight Recorder to measure a simple application that
          does nothing but logging a simple string for about 12 seconds.
        </p>
        <p>
          The application is configured to use Async Loggers, a RandomAccessFile appender and a
          "%d %p %c{1.} [%t] %X{aKey} %m %ex%n" pattern layout).
          It logged about 8.5 million messages and generated a ~600MB log file.
        </p>
        <p>
          Mission Control shows that with Log4j 2.5 this application allocated memory at a rate of about 809 MB/sec,
          resulting in 141 minor collections, with an average pause time of 7 ms.
          Log4j 2.6 does not allocate temporary objects in this configuration, and as a result
          the same application with Log4j 2.6 had an allocation rate of 1.6 MB/sec and 0 (zero) garbage collections.
        </p>
        <table>
          <tr>
            <td>
        <a href="../images/log4j-2.5-FlightRecording.png"><img
            src="../images/log4j-2.5-FlightRecording.png"
            alt="log4j-2.5: allocation rate 809 MB/sec, 141 minor GCs, each pausing 7 ms on avg" /></a>
            </td>
            <td>
              <a href="../images/log4j-2.6-FlightRecording.png"><img
                  src="../images/log4j-2.6-FlightRecording.png"
                  alt="log4j-2.6: allocation rate 1.6 MB/sec, 0 minor or major GCs" /></a>
            </td>
          </tr>
        </table>
      </subsection><commit_msg>LOG4J2-1297 garbagefree.xml small fixes<commit_after><?xml version="1.0"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
  license agreements. See the NOTICE file distributed with this work for additional
  information regarding copyright ownership. The ASF licenses this file to
  You under the Apache License, Version 2.0 (the "License"); you may not use
  this file except in compliance with the License. You may obtain a copy of
  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
  by applicable law or agreed to in writing, software distributed under the
  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
  OF ANY KIND, either express or implied. See the License for the specific
  language governing permissions and limitations under the License. -->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  <properties>
    <title>Garbage-free Steady State Logging</title>
    <author email="<EMAIL>"><NAME></author>
  </properties>
  <body>
    <section name="Garbage-free Steady State Logging">
      <p>
        Different applications have different performance requirements.
        Some only need to worry about throughput, but for many
        the most important performance consideration is latency (response time).
        Users of such applications would consider it a big problem
        if the system becomes unresponsive for more than a few seconds, or even milliseconds in some cases.
        In financial trading for example predictable low latency is so important that it is often considered
        worthwhile to trade off some throughput in return for consistent response time.
      </p>
      <p>
        Garbage collection pauses are a common cause of latency spikes and for many systems
        significant effort is spent on controlling these pauses.
      </p>
      <p>
        Traditionally, logging libraries allocate many temporary objects like log event objects, Strings, byte arrays
        and more during steady state logging.
        This contributes to pressure on the garbage collector and increases the frequency with which GC pauses occur.
        From version 2.6, Log4j can be run in a "garbage free" mode where objects and buffers are reused
        and temporary object allocation is avoided as much as possible.
      </p>
      <p>

      </p>
      <a name="jfr" />
      <subsection name="A Contrived Example">
        <p>
          To highlight the difference, we used Java Flight Recorder to measure a simple application that
          does nothing but logging a simple string for about 12 seconds.
        </p>
        <p>
          The application was configured to use Async Loggers, a RandomAccessFile appender and a
          "%d %p %c{1.} [%t] %m %ex%n" pattern layout.
          It logged about 8.5 million messages and generated a ~600MB log file.
        </p>
        <p>
          Mission Control shows that with Log4j 2.5 this application allocated memory at a rate of about 809 MB/sec,
          resulting in 141 minor collections.
          Log4j 2.6 does not allocate temporary objects in this configuration, and as a result
          the same application with Log4j 2.6 had a memory allocation rate of 1.6 MB/sec and 0 (zero) garbage collections.
        </p>
        <table>
          <tr>
            <td>
        <a href="../images/log4j-2.5-FlightRecording.png"><img
            src="../images/log4j-2.5-FlightRecording.png"
            alt="log4j-2.5: allocation rate 809 MB/sec, 141 minor GCs, each pausing 7 ms on avg" /></a>
            </td>
            <td>
              <a href="../images/log4j-2.6-FlightRecording.png"><img
                  src="../images/log4j-2.6-FlightRecording.png"
                  alt="log4j-2.6: allocation rate 1.6 MB/sec, 0 minor or major GCs" /></a>
            </td>
          </tr>
        </table>
      </subsection>
{'fraction_non_alphanumeric': 0.08009321722065497, 'fraction_numerical': 0.019011406844106463, 'mean_word_length': 2.5826010544815468, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 2, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1196246', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2105, 'n_words': 962}