You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/10/03 20:17:00 UTC

[jira] [Commented] (LOG4J2-3170) EncodingPatternConverter CRLF encoding is slow with large log messages (it has quadratic time complexity)

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

ASF subversion and git services commented on LOG4J2-3170:
---------------------------------------------------------

Commit 1c4f8468083ced1f81c5de791683bd99cc4413f8 in logging-log4j2's branch refs/heads/release-2.x from Gareth Smith
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=1c4f846 ]

LOG4J2-3170 Make the CRLF and HTML pattern converters O(n) in time. (#585)

Previously they had O(n ^ 2) performance in the worst case.

> EncodingPatternConverter CRLF encoding is slow with large log messages (it has quadratic time complexity)
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3170
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3170
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Pattern Converters
>    Affects Versions: 2.14.1
>            Reporter: Gareth Daniel Smith
>            Priority: Minor
>
> This code that escapes newlines is very slow on large log messages where those message contain lots of newline characters. For example "abc" repeated a million times takes less than a second to log, but "a\r\n" repeated a million times takes over 5 minutes (in my test).
> I think it is accurate to say that this code has quadratic time complexity: [https://github.com/apache/logging-log4j2/blame/master/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EncodingPatternConverter.java#L151]
> If necessary I can supply more examples and/or a fix.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)