{"action":"created","issue":{"url":"https://api.github.com/repos/ehcache/ehcache3/issues/387","labels_url":"https://api.github.com/repos/ehcache/ehcache3/issues/387/labels{/name}","comments_url":"https://api.github.com/repos/ehcache/ehcache3/issues/387/comments","events_url":"https://api.github.com/repos/ehcache/ehcache3/issues/387/events","html_url":"https://github.com/ehcache/ehcache3/issues/387","id":70606624,"number":387,"title":"100% CPU utilisation when used as a JSR-107 compliant cache for Spring framework 4.1.4","user":{"login":"drekka","id":153837,"avatar_url":"https://avatars.githubusercontent.com/u/153837?v=3","gravatar_id":"","url":"https://api.github.com/users/drekka","html_url":"https://github.com/drekka","followers_url":"https://api.github.com/users/drekka/followers","following_url":"https://api.github.com/users/drekka/following{/other_user}","gists_url":"https://api.github.com/users/drekka/gists{/gist_id}","starred_url":"https://api.github.com/users/drekka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drekka/subscriptions","organizations_url":"https://api.github.com/users/drekka/orgs","repos_url":"https://api.github.com/users/drekka/repos","events_url":"https://api.github.com/users/drekka/events{/privacy}","received_events_url":"https://api.github.com/users/drekka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-24T06:59:08Z","updated_at":"2015-04-27T10:14:57Z","closed_at":null,"body":"I have the following Java config setup in my Spring container:\r\n\r\n    @Configuration\r\n    @EnableCaching\r\n    public class FXCacheConfig {\r\n\r\n\t@Value(\"${\" + FXConstants.CACHE_RATES_TTL + \"}\")\r\n\tprivate int ratesCacheTTL;\r\n    \r\n    @Bean\r\n\tpublic JCacheManagerFactoryBean cacheFactory() {\r\n\t\treturn new JCacheManagerFactoryBean();\r\n\t}\r\n\r\n\t@Bean\r\n\tpublic CacheManager jCacheManager(javax.cache.CacheManager jsr107CacheManager) {\r\n\r\n\t\tMutableConfiguration<Object, ExchangeRates> config = new MutableConfiguration<>();\r\n\t\tconfig.setStoreByValue(false);\r\n\t\tconfig.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS,\r\n\t\t\t\tthis.ratesCacheTTL)));\r\n\t\tjsr107CacheManager.createCache(FXConstants.CACHE_RATES_NAME, config);\r\n\r\n\t\treturn new JCacheCacheManager(jsr107CacheManager);\r\n\t}\r\n\r\n    } \r\n\r\nI've then run this setup on Jetty 9 and JBoss 8.2. On both servers the CPU goes to 100% (and beyond). If I take this out and replace it with the equivalent Guava or ConcurrentMapCache implementations as per the Spring documents, the server uses <5%. \r\n\r\nI've tried to profile the server but have not been able to isolate the problem. All I can tell so far is that with EHCache 3, my CPUs max out. \r\n\r\nI've also tried removing the cache setup from the above code, and removing all the @Cache... annotations so there is nothing left but the raw setup. CPUs still 100%+.\r\n\r\nAny ideas what to try next?\r\n\r\nDerek "},"comment":{"url":"https://api.github.com/repos/ehcache/ehcache3/issues/comments/96597150","html_url":"https://github.com/ehcache/ehcache3/issues/387#issuecomment-96597150","issue_url":"https://api.github.com/repos/ehcache/ehcache3/issues/387","id":96597150,"user":{"login":"lorban","id":622925,"avatar_url":"https://avatars.githubusercontent.com/u/622925?v=3","gravatar_id":"","url":"https://api.github.com/users/lorban","html_url":"https://github.com/lorban","followers_url":"https://api.github.com/users/lorban/followers","following_url":"https://api.github.com/users/lorban/following{/other_user}","gists_url":"https://api.github.com/users/lorban/gists{/gist_id}","starred_url":"https://api.github.com/users/lorban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorban/subscriptions","organizations_url":"https://api.github.com/users/lorban/orgs","repos_url":"https://api.github.com/users/lorban/repos","events_url":"https://api.github.com/users/lorban/events{/privacy}","received_events_url":"https://api.github.com/users/lorban/received_events","type":"User","site_admin":false},"created_at":"2015-04-27T10:14:57Z","updated_at":"2015-04-27T10:14:57Z","body":"I managed to reproduce the problem and indeed, there seems to be a bug in ehcache 3 that is the cause of this excessive CPU consumption.\n\nIt seems that the statistics thread pool mistakenly was created in a way that it never keeps its threads around, hence every single statistic work ehcache does internally ends up creating a new thread each time. It is that thread creation that consumes unordinate amounts of CPU time, and since those threads only end up doing very minimal work this explains why they don't show up on the jtop radar: most CPU actually is consumed by the OS to create the thread, not to execute any java code.\n\nWe're going to fix this the for the next release, but in the meantime, there fortunately is a workaround: just set the org.ehcache.statisticsExecutor.poolSize system property to 1 and the problem should go away.\n\nThanks for reporting this bug!"}}