Debugging EhCache's SizeOfEngine

Enable Tomcat Logging in Eclipse

http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_do_I_enable_the_JULI_logging_in_a_Tomcat_5.5_Server_instance.3F

Enable size of specific logging

From http://ehcache.org/documentation/configuration/cache-size#sizing-of-cached-entries

  1. Set the net.sf.ehcache.sizeof.verboseDebugLogging system property to true.
  2. Enable debug logs on net.sf.ehcache.pool.sizeof in your chosen implementation of SLF4J.

When running Tomcat from Eclipse #1 can be set in the run configuration for your Tomcat server in the VM arguments section. #2 can be set in a couple of places, depending on where your Tomcat server is looking for the metadata. The "catalina.base" VM argument in the run configuration should point you to the right place. In <catalina base>/conf/logging.properties, you can add the line "net.sf.ehcache.pool.sizeof.level=FINEST" to get all of the logging.

Interpreting the logs

The logs you'll have are very verbose, but there are a few key things to look for.

  • Look for net.sf.ehcache.pool.impl.DefaultSizeOfEngine getUserFilter logs, they will point you to the filter the size of engine is using.
    • INFO: Using user supplied filter @ jar:file:/<path to war>/shindig-server-2.5.0-SNAPSHOT/WEB-INF/lib/shindig-common-2.5.0-SNAPSHOT.jar!/org/apache/shindig/common/cache/ehcache/SizeOfFilter.txt
  • net.sf.ehcache.pool.sizeof.ObjectGraphWalker walk logs will show the results of the full graph walk for each object, so you can see what objects were walked and how big they were computed to be. At the end of the walk a total size in bytes is displayed.
  • Look for WARNING messages that relate to sizeOfPolicy. If the sizeOfPolicy configured in ehcacheConfig.xml is exceeded, EhCache will alert and either continue or abort, depending on the configuration. For debugging one can set the sizeOfPolicy to continue in order to receive the full trace from the ObjectGraphWalker. This can help determine references that shouldn't be walked and that should be added to the SizeOfFilter.txt
  • No labels