Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit aefbfcf

Browse files
committed
Update benchmarks and include GelfLayout.
1 parent 2d7cee7 commit aefbfcf

File tree

7 files changed

+3898
-3218
lines changed

7 files changed

+3898
-3218
lines changed

README.md

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,15 @@ To give an idea, we ran the benchmark with the following settings:
357357

358358
- **CPU:** Intel i7 2.70GHz (x86-64, confined `java` process to a single core
359359
using [`taskset -c 0`](http://www.man7.org/linux/man-pages/man1/taskset.1.html))
360-
- **JVM:** Java HotSpot 1.8.0_192 (`-XX:+TieredCompilation`, `-XX:+AggressiveOpts`)
361-
- **OS:** Xubuntu 18.04.3 (4.15.0-54-generic, x86-64)
362-
- **`LogstashLayout4{Ecs,Json}Layout`** used default settings with the following exceptions:
363-
- **`emptyPropertyExclusionEnabled`:** `false`
360+
- **JVM:** OpenJDK 64-Bit, AdoptOpenJDK, build 25.232-b09
361+
- `-XX:+TieredCompilation`
362+
- `-Dlog4j2.garbagefreeThreadContextMap=true`
363+
- `-Dlog4j2.enableDirectEncoders=true`
364+
- `-Dlog4j2.enable.threadlocals=true`
365+
- `-Dlog4j2.is.webapp=false`
366+
- **OS:** Xubuntu 18.04.3 (4.15.0-70-generic, x86-64)
367+
- **`LogstashLayout4{Ecs,Json,Gelf}Layout`** used default settings with the
368+
following exceptions:
364369
- **`stackTraceEnabled`:** `true`
365370
- **`maxByteCount`:** (4096) 4KiB
366371
- **`JsonLayout`** used in two different flavors:
@@ -371,6 +376,8 @@ To give an idea, we ran the benchmark with the following settings:
371376
- **`EcsLayout`** used with the following configurations:
372377
- **`serviceName`:** `benchmark`
373378
- **`additionalFields`:** `new KeyValuePair[0]`
379+
- **`GelfLayout`** used with the following configurations:
380+
- **`compressionType`:** `off`
374381

375382
The figures for serializing 1,000 `LogEvent`s at each operation are as follows.
376383
(See [`layout-benchmark`](layout-benchmark) directory for the full report.)
@@ -385,65 +392,89 @@ The figures for serializing 1,000 `LogEvent`s at each operation are as follows.
385392
</tr>
386393
</thead>
387394
<tbody>
395+
<tr data-benchmark="liteLogstashLayout4GelfLayout">
396+
<td class="benchmark">liteLogstashLayout4GelfLayout</td>
397+
<td class="op_rate">1,517,062</td>
398+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (100%)</td>
399+
<td class="gc_rate">0.0</td>
400+
</tr>
388401
<tr data-benchmark="liteLogstashLayout4EcsLayout">
389402
<td class="benchmark">liteLogstashLayout4EcsLayout</td>
390-
<td class="op_rate">813,346</td>
391-
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉&nbsp;(100%)</td>
392-
<td class="gc_rate">4,545.0</td>
403+
<td class="op_rate">1,196,255</td>
404+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (79%)</td>
405+
<td class="gc_rate">0.0</td>
393406
</tr>
394-
<tr data-benchmark="liteEcsLayout">
395-
<td class="benchmark">liteEcsLayout</td>
396-
<td class="op_rate">603,469</td>
397-
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉&nbsp;(74%)</td>
398-
<td class="gc_rate">460.9</td>
407+
<tr data-benchmark="liteGelfLayout">
408+
<td class="benchmark">liteGelfLayout</td>
409+
<td class="op_rate">1,184,922</td>
410+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (78%)</td>
411+
<td class="gc_rate">0.0</td>
399412
</tr>
400413
<tr data-benchmark="liteLogstashLayout4JsonLayout">
401414
<td class="benchmark">liteLogstashLayout4JsonLayout</td>
402-
<td class="op_rate">564,456</td>
403-
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉&nbsp;(69%)</td>
404-
<td class="gc_rate">492.7</td>
415+
<td class="op_rate">870,012</td>
416+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉ (57%)</td>
417+
<td class="gc_rate">0.0</td>
418+
</tr>
419+
<tr data-benchmark="liteEcsLayout">
420+
<td class="benchmark">liteEcsLayout</td>
421+
<td class="op_rate">836,648</td>
422+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉ (55%)</td>
423+
<td class="gc_rate">0.0</td>
405424
</tr>
406425
<tr data-benchmark="liteDefaultJsonLayout">
407426
<td class="benchmark">liteDefaultJsonLayout</td>
408-
<td class="op_rate">294,590</td>
409-
<td class="op_rate_bar">▉▉▉▉▉▉▉&nbsp;(36%)</td>
410-
<td class="gc_rate">5,101,398.2</td>
427+
<td class="op_rate">506,985</td>
428+
<td class="op_rate_bar">▉▉▉▉▉▉▉ (33%)</td>
429+
<td class="gc_rate">5,331,680.0</td>
411430
</tr>
412431
<tr data-benchmark="liteCustomJsonLayout">
413432
<td class="benchmark">liteCustomJsonLayout</td>
414-
<td class="op_rate">258,302</td>
415-
<td class="op_rate_bar">▉▉▉▉▉▉▉&nbsp;(32%)</td>
416-
<td class="gc_rate">5,516,833.5</td>
433+
<td class="op_rate">446,243</td>
434+
<td class="op_rate_bar">▉▉▉▉▉▉ (29%)</td>
435+
<td class="gc_rate">5,740,400.0</td>
417436
</tr>
418437
<tr data-benchmark="fullLogstashLayout4JsonLayout">
419438
<td class="benchmark">fullLogstashLayout4JsonLayout</td>
420-
<td class="op_rate">70,755</td>
421-
<td class="op_rate_bar">▉▉&nbsp;(9%)</td>
422-
<td class="gc_rate">108,258.8</td>
439+
<td class="op_rate">118,294</td>
440+
<td class="op_rate_bar">▉▉ (8%)</td>
441+
<td class="gc_rate">104,000.1</td>
442+
</tr>
443+
<tr data-benchmark="fullLogstashLayout4GelfLayout">
444+
<td class="benchmark">fullLogstashLayout4GelfLayout</td>
445+
<td class="op_rate">73,102</td>
446+
<td class="op_rate_bar">▉ (5%)</td>
447+
<td class="gc_rate">35,663,200.3</td>
423448
</tr>
424449
<tr data-benchmark="fullLogstashLayout4EcsLayout">
425450
<td class="benchmark">fullLogstashLayout4EcsLayout</td>
426-
<td class="op_rate">41,913</td>
427-
<td class="op_rate_bar">▉&nbsp;(5%)</td>
428-
<td class="gc_rate">35,690,881.3</td>
451+
<td class="op_rate">60,569</td>
452+
<td class="op_rate_bar">▉ (4%)</td>
453+
<td class="gc_rate">35,631,200.4</td>
429454
</tr>
430455
<tr data-benchmark="fullEcsLayout">
431456
<td class="benchmark">fullEcsLayout</td>
432-
<td class="op_rate">16,594</td>
433-
<td class="op_rate_bar">▉&nbsp;(2%)</td>
434-
<td class="gc_rate">46,495,593.1</td>
457+
<td class="op_rate">27,887</td>
458+
<td class="op_rate_bar">▉ (2%)</td>
459+
<td class="gc_rate">46,479,200.5</td>
460+
</tr>
461+
<tr data-benchmark="fullGelfLayout">
462+
<td class="benchmark">fullGelfLayout</td>
463+
<td class="op_rate">21,458</td>
464+
<td class="op_rate_bar">▉ (1%)</td>
465+
<td class="gc_rate">58,911,200.7</td>
435466
</tr>
436467
<tr data-benchmark="fullDefaultJsonLayout">
437468
<td class="benchmark">fullDefaultJsonLayout</td>
438-
<td class="op_rate">8,484</td>
439-
<td class="op_rate_bar">▉&nbsp;(1%)</td>
440-
<td class="gc_rate">234,422,375.7</td>
469+
<td class="op_rate">13,513</td>
470+
<td class="op_rate_bar">▉ (1%)</td>
471+
<td class="gc_rate">234,102,401.5</td>
441472
</tr>
442473
<tr data-benchmark="fullCustomJsonLayout">
443474
<td class="benchmark">fullCustomJsonLayout</td>
444-
<td class="op_rate">8,456</td>
445-
<td class="op_rate_bar">▉&nbsp;(1%)</td>
446-
<td class="gc_rate">234,624,867.7</td>
475+
<td class="op_rate">13,511</td>
476+
<td class="op_rate_bar">▉ (1%)</td>
477+
<td class="gc_rate">234,238,401.5</td>
447478
</tr>
448479
</tbody>
449480
</table>
@@ -460,7 +491,7 @@ Let us try to answer some common questions:
460491
`ObjectMapper`, which needs to walk over the class fields via reflection and
461492
perform heavy branching and intermediate object instantiation. On the
462493
contrary, `log4j2-logstash-layout` parses the given template once and
463-
compiles an (almost) garbage- and (to a certain extent) branching-free
494+
compiles a (mostly) garbage- and (to a certain extent) branching-free
464495
JSON generator employing Jackson `JsonGenerator`.
465496

466497
- **Why is `log4j2-logstash-layout` is not totally garbage-free?**
@@ -474,7 +505,7 @@ Let us try to answer some common questions:
474505
`Long`, or `byte[]`.
475506

476507
- **How can one run the benchmark on his/her machine?** After a fresh
477-
`mvn clean package` within the source directory, run
508+
`mvn clean verify` within the source directory, run
478509
`layout-benchmark/benchmark.py`.
479510

480511
- **What about thread-local allocations?** Even though Log4j 2 exposes a

layout-benchmark/benchmark.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_benchmark():
5050
mvn_output_file = get_mvn_output_file()
5151
with open(mvn_output_file, "w") as mvn_output_file_handle:
5252
env = os.environ.copy()
53-
env["MAVEN_OPTS"] = "-XX:+TieredCompilation -XX:+AggressiveOpts"
53+
env["MAVEN_OPTS"] = "-XX:+TieredCompilation"
5454
popen = subprocess.Popen(
5555
["taskset",
5656
"-c", "0",
@@ -60,6 +60,8 @@ def run_benchmark():
6060
"exec:java",
6161
"-Dlog4j2.garbagefreeThreadContextMap=true",
6262
"-Dlog4j2.enableDirectEncoders=true",
63+
"-Dlog4j2.enable.threadlocals=true",
64+
"-Dlog4j2.is.webapp=false",
6365
"-Dlog4j2.logstashLayoutBenchmark.jsonOutputFile={}".format(json_output_file)],
6466
env=env,
6567
bufsize=1,

layout-benchmark/results.html

Lines changed: 100 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -17,80 +17,104 @@
1717
{ font-weight: bold }
1818
#results #footnotes { font-size: 0.8em; }
1919
</style>
20-
<div id="results">
21-
<table>
22-
<thead>
23-
<tr>
24-
<th>Benchmark</th>
25-
<th colspan="2">ops/sec<sup>*</sup></th>
26-
<th>MB/sec<sup>*</sup></th>
27-
</tr>
28-
</thead>
29-
<tbody>
30-
<tr data-benchmark="liteLogstashLayout4EcsLayout">
31-
<td class="benchmark">liteLogstashLayout4EcsLayout</td>
32-
<td class="op_rate">813,346</td>
33-
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (100%)</td>
34-
<td class="gc_rate">4,545.0</td>
35-
</tr>
36-
<tr data-benchmark="liteEcsLayout">
37-
<td class="benchmark">liteEcsLayout</td>
38-
<td class="op_rate">603,469</td>
39-
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (74%)</td>
40-
<td class="gc_rate">460.9</td>
41-
</tr>
42-
<tr data-benchmark="liteLogstashLayout4JsonLayout">
43-
<td class="benchmark">liteLogstashLayout4JsonLayout</td>
44-
<td class="op_rate">564,456</td>
45-
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (69%)</td>
46-
<td class="gc_rate">492.7</td>
47-
</tr>
48-
<tr data-benchmark="liteDefaultJsonLayout">
49-
<td class="benchmark">liteDefaultJsonLayout</td>
50-
<td class="op_rate">294,590</td>
51-
<td class="op_rate_bar">▉▉▉▉▉▉▉ (36%)</td>
52-
<td class="gc_rate">5,101,398.2</td>
53-
</tr>
54-
<tr data-benchmark="liteCustomJsonLayout">
55-
<td class="benchmark">liteCustomJsonLayout</td>
56-
<td class="op_rate">258,302</td>
57-
<td class="op_rate_bar">▉▉▉▉▉▉▉ (32%)</td>
58-
<td class="gc_rate">5,516,833.5</td>
59-
</tr>
60-
<tr data-benchmark="fullLogstashLayout4JsonLayout">
61-
<td class="benchmark">fullLogstashLayout4JsonLayout</td>
62-
<td class="op_rate">70,755</td>
63-
<td class="op_rate_bar">▉▉ (9%)</td>
64-
<td class="gc_rate">108,258.8</td>
65-
</tr>
66-
<tr data-benchmark="fullLogstashLayout4EcsLayout">
67-
<td class="benchmark">fullLogstashLayout4EcsLayout</td>
68-
<td class="op_rate">41,913</td>
69-
<td class="op_rate_bar">▉ (5%)</td>
70-
<td class="gc_rate">35,690,881.3</td>
71-
</tr>
72-
<tr data-benchmark="fullEcsLayout">
73-
<td class="benchmark">fullEcsLayout</td>
74-
<td class="op_rate">16,594</td>
75-
<td class="op_rate_bar">▉ (2%)</td>
76-
<td class="gc_rate">46,495,593.1</td>
77-
</tr>
78-
<tr data-benchmark="fullDefaultJsonLayout">
79-
<td class="benchmark">fullDefaultJsonLayout</td>
80-
<td class="op_rate">8,484</td>
81-
<td class="op_rate_bar">▉ (1%)</td>
82-
<td class="gc_rate">234,422,375.7</td>
83-
</tr>
84-
<tr data-benchmark="fullCustomJsonLayout">
85-
<td class="benchmark">fullCustomJsonLayout</td>
86-
<td class="op_rate">8,456</td>
87-
<td class="op_rate_bar">▉ (1%)</td>
88-
<td class="gc_rate">234,624,867.7</td>
89-
</tr>
90-
</tbody>
91-
</table>
92-
<p id="footnotes">
93-
<sup>*</sup> 99<sup>th</sup> percentile
94-
</p>
95-
</div>
20+
<div id="results">
21+
<table>
22+
<thead>
23+
<tr>
24+
<th>Benchmark</th>
25+
<th colspan="2">ops/sec<sup>*</sup></th>
26+
<th>B/op<sup>*</sup></th>
27+
</tr>
28+
</thead>
29+
<tbody>
30+
<tr data-benchmark="liteLogstashLayout4GelfLayout">
31+
<td class="benchmark">liteLogstashLayout4GelfLayout</td>
32+
<td class="op_rate">1,517,062</td>
33+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (100%)</td>
34+
<td class="gc_rate">0.0</td>
35+
</tr>
36+
<tr data-benchmark="liteLogstashLayout4EcsLayout">
37+
<td class="benchmark">liteLogstashLayout4EcsLayout</td>
38+
<td class="op_rate">1,196,255</td>
39+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (79%)</td>
40+
<td class="gc_rate">0.0</td>
41+
</tr>
42+
<tr data-benchmark="liteGelfLayout">
43+
<td class="benchmark">liteGelfLayout</td>
44+
<td class="op_rate">1,184,922</td>
45+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (78%)</td>
46+
<td class="gc_rate">0.0</td>
47+
</tr>
48+
<tr data-benchmark="liteLogstashLayout4JsonLayout">
49+
<td class="benchmark">liteLogstashLayout4JsonLayout</td>
50+
<td class="op_rate">870,012</td>
51+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉ (57%)</td>
52+
<td class="gc_rate">0.0</td>
53+
</tr>
54+
<tr data-benchmark="liteEcsLayout">
55+
<td class="benchmark">liteEcsLayout</td>
56+
<td class="op_rate">836,648</td>
57+
<td class="op_rate_bar">▉▉▉▉▉▉▉▉▉▉▉ (55%)</td>
58+
<td class="gc_rate">0.0</td>
59+
</tr>
60+
<tr data-benchmark="liteDefaultJsonLayout">
61+
<td class="benchmark">liteDefaultJsonLayout</td>
62+
<td class="op_rate">506,985</td>
63+
<td class="op_rate_bar">▉▉▉▉▉▉▉ (33%)</td>
64+
<td class="gc_rate">5,331,680.0</td>
65+
</tr>
66+
<tr data-benchmark="liteCustomJsonLayout">
67+
<td class="benchmark">liteCustomJsonLayout</td>
68+
<td class="op_rate">446,243</td>
69+
<td class="op_rate_bar">▉▉▉▉▉▉ (29%)</td>
70+
<td class="gc_rate">5,740,400.0</td>
71+
</tr>
72+
<tr data-benchmark="fullLogstashLayout4JsonLayout">
73+
<td class="benchmark">fullLogstashLayout4JsonLayout</td>
74+
<td class="op_rate">118,294</td>
75+
<td class="op_rate_bar">▉▉ (8%)</td>
76+
<td class="gc_rate">104,000.1</td>
77+
</tr>
78+
<tr data-benchmark="fullLogstashLayout4GelfLayout">
79+
<td class="benchmark">fullLogstashLayout4GelfLayout</td>
80+
<td class="op_rate">73,102</td>
81+
<td class="op_rate_bar">▉ (5%)</td>
82+
<td class="gc_rate">35,663,200.3</td>
83+
</tr>
84+
<tr data-benchmark="fullLogstashLayout4EcsLayout">
85+
<td class="benchmark">fullLogstashLayout4EcsLayout</td>
86+
<td class="op_rate">60,569</td>
87+
<td class="op_rate_bar">▉ (4%)</td>
88+
<td class="gc_rate">35,631,200.4</td>
89+
</tr>
90+
<tr data-benchmark="fullEcsLayout">
91+
<td class="benchmark">fullEcsLayout</td>
92+
<td class="op_rate">27,887</td>
93+
<td class="op_rate_bar">▉ (2%)</td>
94+
<td class="gc_rate">46,479,200.5</td>
95+
</tr>
96+
<tr data-benchmark="fullGelfLayout">
97+
<td class="benchmark">fullGelfLayout</td>
98+
<td class="op_rate">21,458</td>
99+
<td class="op_rate_bar">▉ (1%)</td>
100+
<td class="gc_rate">58,911,200.7</td>
101+
</tr>
102+
<tr data-benchmark="fullDefaultJsonLayout">
103+
<td class="benchmark">fullDefaultJsonLayout</td>
104+
<td class="op_rate">13,513</td>
105+
<td class="op_rate_bar">▉ (1%)</td>
106+
<td class="gc_rate">234,102,401.5</td>
107+
</tr>
108+
<tr data-benchmark="fullCustomJsonLayout">
109+
<td class="benchmark">fullCustomJsonLayout</td>
110+
<td class="op_rate">13,511</td>
111+
<td class="op_rate_bar">▉ (1%)</td>
112+
<td class="gc_rate">234,238,401.5</td>
113+
</tr>
114+
</tbody>
115+
</table>
116+
<p id="footnotes">
117+
<sup>*</sup> 99<sup>th</sup> percentile
118+
</p>
119+
</div>
96120
</body>

0 commit comments

Comments
 (0)