Skip to content

Commit e84a46c

Browse files
committed
tiny wording improvments and corrections
1 parent 61c2c6f commit e84a46c

File tree

6 files changed

+238
-250
lines changed

6 files changed

+238
-250
lines changed

src/site/antora/modules/ROOT/pages/manual/async.adoc

+36-36
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
Remko Popma <[email protected]>
1919
2020
Asynchronous logging can improve your application's performance by
21-
executing the I/O operations in a separate thread. Log4j 2 makes a
22-
number of improvements in this area.
21+
executing the I/O operations in a separate thread.
22+
Log4j 2 makes several improvements in this area.
2323
24-
* *Asynchronous Loggers* are a new addition in Log4j 2. Their aim is to
25-
return from the call to Logger.log to the application as soon as
24+
* *Asynchronous Loggers* are a new addition in Log4j 2. They aim to
25+
return the call to Logger.log to the application as soon as
2626
possible. You can choose between making all Loggers asynchronous or
2727
using a mixture of synchronous and asynchronous Loggers. Making all
2828
Loggers asynchronous will give the best performance, while mixing gives
@@ -35,8 +35,8 @@ latency.
3535
been enhanced to flush to disk at the end of a batch (when the queue is
3636
empty). This produces the same result as configuring
3737
"immediateFlush=true", that is, all received log events are always
38-
available on disk, but is more efficient because it does not need to
39-
touch the disk on each and every log event. (Async Appenders use
38+
available on disk but are more efficient because it does not need to
39+
touch the disk on every log event. (Async Appenders use
4040
ArrayBlockingQueue internally and do not need the disruptor jar on the
4141
classpath.)
4242
@@ -58,7 +58,7 @@ to log bursts of messages. Async logging can help prevent or dampen
5858
latency spikes by shortening the wait time until the next message can be
5959
logged. If the queue size is configured large enough to handle the
6060
burst, asynchronous logging will help prevent your application from
61-
falling behind (as much) during a sudden increase of activity.
61+
falling behind (as much) during a sudden increase in activity.
6262
* Lower logging response time link:#Latency[latency]. Response time
6363
latency is the time it takes for a call to Logger.log to return under a
6464
given workload. Asynchronous Loggers have consistently lower latency
@@ -71,8 +71,8 @@ exception is thrown, it is less easy for an asynchronous logger or
7171
appender to signal this problem to the application. This can partly be
7272
alleviated by configuring an `ExceptionHandler`, but this may still not
7373
cover all cases. For this reason, if logging is part of your business
74-
logic, for example if you are using Log4j as an audit logging framework,
75-
we would recommend to synchronously log those audit messages. (Note that
74+
logic, for example, if you are using Log4j as an audit logging framework,
75+
we would recommend synchronously logging those audit messages. (Note that
7676
you can still link:#MixedSync-Async[combine] them and use asynchronous
7777
logging for debug/trace logging in addition to synchronous logging for
7878
the audit trail.)
@@ -85,7 +85,7 @@ modified later. It is safe to asynchronously log mutable objects because
8585
most
8686
link:../javadoc/log4j-api/org/apache/logging/log4j/message/Message.html[`Message`]
8787
implementations built-in to Log4j take a snapshot of the parameters.
88-
There are some exceptions however:
88+
There are some exceptions, however:
8989
link:../javadoc/log4j-api/org/apache/logging/log4j/message/MapMessage.html[`MapMessage`]
9090
and
9191
link:../javadoc/log4j-api/org/apache/logging/log4j/message/StructuredDataMessage.html[`StructuredDataMessage`]
@@ -98,14 +98,15 @@ link:../javadoc/log4j-api/org/apache/logging/log4j/message/Message.html[`Message
9898
implementations should be designed with asynchronous use in mind, and
9999
either take a snapshot of their parameters at construction time, or
100100
document their thread-safety characteristics.
101+
101102
* If your application is running in an environment where CPU resources
102103
are scarce, like a machine with one CPU with a single core, starting
103104
another thread is not likely to give better performance.
104105
* If the _sustained rate_ at which your application is logging messages
105106
is faster than the maximum sustained throughput of the underlying
106107
appender, the queue will fill up and the application will end up logging
107108
at the speed of the slowest appender. If this happens, consider
108-
selecting a xref:manual/performance.adoc#whichAppender[faster appender], or
109+
selecting an xref:manual/performance.adoc#whichAppender[faster appender], or
109110
logging less. If neither of these is an option, you may get better
110111
throughput and fewer latency spikes by logging synchronously.
111112
@@ -116,7 +117,7 @@ NOTE: _Log4j-2.9 and higher require disruptor-3.3.4.jar or higher on the
116117
classpath. Prior to Log4j-2.9, disruptor-3.0.0.jar or higher was
117118
required._
118119
119-
This is simplest to configure and gives the best performance.
120+
This is the simplest to configure and gives the best performance.
120121
To make all loggers asynchronous, add the disruptor jar to the classpath and set the system property xref:manual/systemproperties.adoc#log4j2.contextSelector[log4j2.contextSelector] to `org.apache.logging.log4j.core.async.AsyncLoggerContextSelector` or `org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector`.
121122
122123
By default, link:#Location[location] is not passed to the I/O thread by
@@ -190,17 +191,17 @@ and `log4j2.discardThreshold`].
190191
== Mixing Synchronous and Asynchronous Loggers
191192
192193
NOTE: _Log4j-2.9 and higher require disruptor-3.3.4.jar or higher on the
193-
classpath. Prior to Log4j-2.9, disruptor-3.0.0.jar or higher was
194-
required. There is no need to set system property "Log4jContextSelector"
194+
classpath. Before Log4j-2.9, disruptor-3.0.0.jar or higher was
195+
required. There is no need to set the system property "Log4jContextSelector"
195196
to any value._
196197
197198
Synchronous and asynchronous loggers can be combined in configuration.
198199
This gives you more flexibility at the cost of a slight loss in
199200
performance (compared to making all loggers asynchronous). Use the
200-
`<asyncRoot>` or `<asyncLogger>` configuration elements to specify the
201+
`<asyncRoot>` or `<asyncLogger>` configuration elements specify the
201202
loggers that need to be asynchronous. A configuration can contain only
202203
one root logger (either a `<root>` or an `<asyncRoot>` element), but
203-
otherwise async and non-async loggers may be combined. For example, a
204+
otherwise, async and non-async loggers may be combined. For example, a
204205
configuration file containing `<asyncLogger>` elements can also contain
205206
`<root>` and `<logger>` elements for the synchronous loggers.
206207
@@ -308,7 +309,7 @@ public interface AsyncWaitStrategyFactory {
308309
The specified class must also have a public no-argument constructor;
309310
Log4j will instantiate an instance of the specified factory class and use this factory to create the WaitStrategy used by all Async Loggers.
310311
311-
WaitStrategy-related system properties are ignored if a `AsyncWaitStrategyFactory` is configured.
312+
WaitStrategy-related system properties are ignored if an `AsyncWaitStrategyFactory` is configured.
312313
313314
314315
[#Location]
@@ -338,7 +339,7 @@ logging with location is 30-100 times slower than without location. For
338339
this reason, asynchronous loggers and asynchronous appenders do not
339340
include location information by default.
340341
341-
You can override the default behaviour in your logger or asynchronous
342+
You can override the default behavior in your logger or asynchronous
342343
appender configuration by specifying `includeLocation="true"`.
343344
344345
[#Performance]
@@ -378,10 +379,10 @@ higher throughput than sync loggers.]
378379
379380
=== Asynchronous Throughput Comparison with Other Logging Packages
380381
381-
We also compared peak throughput of asynchronous loggers to the
382+
We also compared the peak throughput of asynchronous loggers to the
382383
synchronous loggers and asynchronous appenders available in other
383384
logging packages, specifically log4j-1.2.17 and logback-1.0.10, with
384-
similar results. For asynchronous appenders, total logging throughput of
385+
similar results. For asynchronous appenders, the total logging throughput of
385386
all threads together remains roughly constant when adding more threads.
386387
Asynchronous loggers make more effective use of the multiple cores
387388
available on the machine in multi-threaded scenarios.
@@ -457,14 +458,13 @@ threads
457458
458459
This section has been rewritten with the Log4j 2.6 release. The
459460
previous version only reported _service time_ instead of _response
460-
time_. See the xref:manual/performance.adoc#responseTime[response time] side
461-
bar on the performance page on why this is too optimistic. Furthermore
462-
the previous version reported average latency, which does not make sense
461+
time_. See the xref:manual/performance.adoc#responseTime[response time] sidebar on the performance page on why this is too optimistic.
462+
Furthermore, the previous version reported average latency, which does not make sense
463463
since latency is not a normal distribution. Finally, the previous
464464
version of this section only reported the maximum latency of up to
465465
99.99% of the measurements, which does not tell you how bad the worst
466466
0.01% were. This is unfortunate because often the "outliers" are all
467-
that matter when it comes to response time. From this release we will
467+
that matter when it comes to response time. From this release, we will
468468
try to do better and report response time latency across the full range
469469
of percentages, including all the outliers. Our thanks to Gil Tene for
470470
his http://www.infoq.com/presentations/latency-response-time[How NOT to
@@ -473,11 +473,11 @@ the "Oh s#@t!" presentation.)
473473
474474
xref:manual/performance.adoc#responseTime[Response time] is how long it
475475
takes to log a message under a certain load. What is often reported as
476-
latency is actually _service time_: how long it took to perform the
477-
operation. This hides the fact that a single spike in service time adds
478-
queueing delay for many of the subsequent operations. Service time is
476+
latency is _service time_: how long it took to operate.
477+
This hides the fact that a single spike in service time adds
478+
a queueing delay for many of the subsequent operations. Service time is
479479
easy to measure (and often looks good on paper) but is irrelevant for
480-
users since it omits the time spent waiting for service. For this reason
480+
users since it omits the time spent waiting for service. For this reason,
481481
we report response time: service time plus wait time.
482482
483483
The response time test results below were all derived from running the
@@ -494,9 +494,9 @@ wait strategy reduces some jitter.)
494494
* -XX:CompileCommand=dontinline,org.apache.logging.log4j.core.async.perftest.NoOpIdleStrategy::idle
495495
* -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps
496496
-XX:+PrintTenuringDistribution -XX:+PrintGCApplicationConcurrentTime
497-
-XX:+PrintGCApplicationStoppedTime (to eyeball GC and safepoint pauses)
497+
-XX:+PrintGCApplicationStoppedTime (to eyeball GC and savepoint pauses)
498498
499-
The graph below compares response time latency of the
499+
The graph below compares the response time latency of the
500500
ArrayBlockingQueue-based asynchronous appenders in Logback 1.1.7, Log4j
501501
1.2.17 to the various options for asynchronous logging that Log4j 2.6
502502
offers. Under a workload of 128,000 messages per second, using 16
@@ -506,14 +506,14 @@ orders of magnitude larger than Log4j 2.
506506
507507
image:ResponseTimeAsyncLogging16Threads_8kEach.png[When 16
508508
threads generate a total workload of 128,000 msg/sec, Logback 1.1.7 and
509-
Log4j 1.2.17 experience latency spikes that are orders of magnitude
509+
Log4j 1.2.17 experiences latency spikes that are orders of magnitude
510510
larger than Log4j 2]
511511
512512
The graph below zooms in on the Log4j 2 results for the same test. We
513513
see that the worst-case response time is highest for the
514514
ArrayBlockingQueue-based Async Appender.
515515
xref:manual/garbagefree.adoc[Garbage-free] async loggers have the best response
516-
time behaviour.
516+
time behavior.
517517
518518
image:ResponseTimeAsyncLogging16Threads_8kEachLog4j2Only-labeled.png[image]
519519
@@ -522,14 +522,14 @@ image:ResponseTimeAsyncLogging16Threads_8kEachLog4j2Only-labeled.png[image]
522522
523523
Asynchronous Loggers are implemented using the
524524
https://lmax-exchange.github.io/disruptor/[LMAX Disruptor] inter-thread
525-
messaging library. From the LMAX web site:
525+
messaging library. From the LMAX website:
526526
527527
____
528528
...using queues to pass data between stages of the system was
529-
introducing latency, so we focused on optimising this area. The
529+
introducing latency, so we focused on optimizing this area. The
530530
Disruptor is the result of our research and testing. We found that cache
531-
misses at the CPU-level, and locks requiring kernel arbitration are both
532-
extremely costly, so we created a framework which has "mechanical
531+
misses at the CPU level, and locks requiring kernel arbitration are both
532+
extremely costly, so we created a framework that has "mechanical
533533
sympathy" for the hardware it's running on, and that's lock-free.
534534
____
535535

0 commit comments

Comments
 (0)