[ 
https://issues.apache.org/jira/browse/LOG4J2-1349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Remko Popma updated LOG4J2-1349:
--------------------------------
    Attachment: v2_ThreadContextPut.png
                v2_DataStructOpsPerfMediumDataSet.png
                v2_DataStructOpsPerfSmallDataSet.png
                v2_InjectWithConfigProperties.png
                v2_InjectWithoutConfigProperties.png
                v2_ThreadContextGet.png

*Corrected & Additional Benchmarks*

!v2_ThreadContextPut.png!
How long it takes to add a single key-value pair in a ThreadContext that 
already contains 5, 50 or 500 elements.

!v2_ThreadContextGet.png!
How long it takes to get a single key-value pair from a ThreadContext that 
contains 5, 50 or 500 elements.

!v2_InjectWithoutConfigProperties.png!
Injecting is the operation of copying data from the thread context to a log 
event. "Inject without config properties" is the happy case where there are no 
List<Property> key-value pairs from the configuration. For a copy-on-write 
thread context we can use the current thread context snapshot without any 
further modifications. This is very fast.

"Legacy" means the Log4jLogEvent::createMap implementation that is in current 
master (copy from the ThreadContext's Map<String,String> to the LogEvent's 
Map<String,String> context map).

"Default" means the ThreadContext uses a Map<String, String> but the LogEvent 
has a ContextData field.

!v2_InjectWithConfigProperties.png!
The other inject case is where we need to copy data from _both_ the thread 
context _and_ the configuration's List<Property> key-value pairs. Here we 
cannot just use the reference; we need to do some additional copying even if 
the thread context is copy-on-write.

Here also, "Legacy" means the Log4jLogEvent::createMap implementation that is 
in current master (copy from the ThreadContext's Map<String,String> to the 
LogEvent's Map<String,String> context map), and "Default" means the 
ThreadContext uses a Map<String, String> but the LogEvent has a ContextData 
field.

!v2_DataStructOpsPerfSmallDataSet.png!
Fixed benchmark to measure a single put and a single get operation against a 
data structure containing 5 items.

!v2_DataStructOpsPerfMediumDataSet.png!
Fixed benchmark to measure a single put and a single get operation against a 
data structure containing 500 items.


> Garbage-free ThreadContext map
> ------------------------------
>
>                 Key: LOG4J2-1349
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1349
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: API
>    Affects Versions: 2.5
>            Reporter: Remko Popma
>            Assignee: Remko Popma
>             Fix For: 2.7
>
>         Attachments: DataStructOpsPerfMediumDataSet.png, 
> DataStructOpsPerfSmallDataSet.png, InjectWithConfigProperties.png, 
> InjectWithoutConfigProperties.png, ThreadContextPut.png, 
> v2_DataStructOpsPerfMediumDataSet.png, v2_DataStructOpsPerfSmallDataSet.png, 
> v2_InjectWithConfigProperties.png, v2_InjectWithoutConfigProperties.png, 
> v2_ThreadContextGet.png, v2_ThreadContextPut.png
>
>
> The current ThreadContext map and stack implementations allocate temporary 
> objects. This ticket is to investigate and track the work for alternative 
> implementations that are garbage-free.
> Both DefaultThreadContextMap and DefaultThreadContextStack are copy-on-write 
> data structures: each modification replaces the ThreadLocal object with a 
> modified copy. The advantage of this approach is that there is no need to 
> make a copy for each LogEvent.
> Also, DefaultThreadContextMap uses a JDK map, the JDK collections tend to 
> allocate a lot of temporary objects.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to