Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-7427

QNameCache performance patch for Dom4j



      Dom4j can not scale well under heavy concurrent load. We met a highly contest synchronized problem in sesame project. To complete fix this problem, we need to wait Dom4j update or move to other xml parsers. Either choice will take a long time to finish. So i create a patch for the QNameCache synchronized hotspot, if you see the same problem in your product, you can use this patch temporarily, a complete fix is on the way. Before you start to do anything, you have to make sure you have the same problem, as we had:

      If you system is very slow under heavy concurrently load, do a few thread dumps, if you find a lot of threads are blocking on org.dom4j.tree.QNameCache, then you have the same problem.

      This patch is against dom4j-1.6.1!

      This patch changes the synchronized map to threadlocal map, which will increase your system's memory footprint. So you have to make sure the memory usage increase is acceptable for your system. Usually if your system is only parsering/generating limited numbers xml tag names(Be aware! It is tag names number, not tag number), it is very safe to use this patch. But if your system is using to parse/generate a lot of xmls with random tag names, you can not use this patch, it may cause OOM!

      How to apply this patch?
      Download the file in the attach, unzip it. Copy the dir to classes dir of your server. The classes files will be loaded before the original Dom4j QNameCache.
      To make sure the patched class is loaded, turn on debug log for org.dom4j.tree.QNameCache category. You should see "You are using the patched version QNameCache of Dom4j!" output. Then turn off the log, try to performance test your system again. The highly contest of QNameCache should disappear.


        Issue Links



              shuyang.zhou Shuyang Zhou
              shuyang.zhou Shuyang Zhou
              Kiyoshi Lee Kiyoshi Lee
              0 Vote for this issue
              0 Start watching this issue




                  Version Package
                  --Sprint 11/12
                  6.2.0 CE M2