Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1611

Improve performance of ThreadContextDataInjector.ForDefaultThreadContextMap

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.7
    • Core
    • None

    Description

      Current implementation of ThreadContextDataInjector.ForDefaultThreadContextMap::injectContextData always copies all elements from the ThreadContext into the reused StringMap of the LogEvent.

      Since the DefaultThreadContextMap is used in web applications (when non-JDK thread-locals are not available and Log4j is not garbage-free), we don't need to worry about creating additional objects. We can speed up the injectContextData method by wrapping the context data Map<String, String> in a decorator object that implements the StringMap interface.

      Attachments

        1. ThreadContext-PutAndRemove.png
          34 kB
          Remko Popma
        2. ThreadContext-Get.png
          30 kB
          Remko Popma
        3. InjectWithProperties.png
          41 kB
          Remko Popma
        4. InjectWithoutProperties.png
          36 kB
          Remko Popma

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rpopma Remko Popma
            rpopma Remko Popma
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment