{"action":"created","issue":{"url":"https://api.github.com/repos/google/guava/issues/2393","repository_url":"https://api.github.com/repos/google/guava","labels_url":"https://api.github.com/repos/google/guava/issues/2393/labels{/name}","comments_url":"https://api.github.com/repos/google/guava/issues/2393/comments","events_url":"https://api.github.com/repos/google/guava/issues/2393/events","html_url":"https://github.com/google/guava/issues/2393","id":134256645,"number":2393,"title":"Performance of reading from cache","user":{"login":"gogainda","id":379758,"avatar_url":"https://avatars.githubusercontent.com/u/379758?v=3","gravatar_id":"","url":"https://api.github.com/users/gogainda","html_url":"https://github.com/gogainda","followers_url":"https://api.github.com/users/gogainda/followers","following_url":"https://api.github.com/users/gogainda/following{/other_user}","gists_url":"https://api.github.com/users/gogainda/gists{/gist_id}","starred_url":"https://api.github.com/users/gogainda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogainda/subscriptions","organizations_url":"https://api.github.com/users/gogainda/orgs","repos_url":"https://api.github.com/users/gogainda/repos","events_url":"https://api.github.com/users/gogainda/events{/privacy}","received_events_url":"https://api.github.com/users/gogainda/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/guava/labels/package:%20cache","name":"package: cache","color":"207de5"},{"url":"https://api.github.com/repos/google/guava/labels/type:%20performance","name":"type: performance","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-17T11:38:40Z","updated_at":"2016-02-18T09:52:21Z","closed_at":null,"body":"In my case average time of reading from cache is about 4.567693ms, but in some cases this time could slow down to 13ms. What could be an issue here?\r\n\r\n```java\r\nprivate final val cachedData = CacheBuilder.newBuilder\r\n    .expireAfterWrite(5, TimeUnit.MINUTES)\r\n    .recordStats()\r\n    .build(new CacheLoader[Set[String], Set[String]] {\r\n      override def load(aggregateIds: Set[String]): Set[String] = {        \r\n        fetchSomeDataFromDB\r\n      }\r\n    })\r\n```\r\n\r\nI have a file with 40000 row, for each row  I read from cache. For first file reading from cache is really fast, but when I process this file again - reading from cache slows down to 13ms. aggregateIds for 2 files the same, so I expect the same performance.\r\n\r\nStats are following\r\n```\r\nhitCount = 67172\r\nmissCount = 4\r\nloadSuccessCount = 4\r\nloadExceptionCount = 0\r\ntotalLoadTime = 13476244193\r\nevictionCount = 3\r\n```"},"comment":{"url":"https://api.github.com/repos/google/guava/issues/comments/185632602","html_url":"https://github.com/google/guava/issues/2393#issuecomment-185632602","issue_url":"https://api.github.com/repos/google/guava/issues/2393","id":185632602,"user":{"login":"gogainda","id":379758,"avatar_url":"https://avatars.githubusercontent.com/u/379758?v=3","gravatar_id":"","url":"https://api.github.com/users/gogainda","html_url":"https://github.com/gogainda","followers_url":"https://api.github.com/users/gogainda/followers","following_url":"https://api.github.com/users/gogainda/following{/other_user}","gists_url":"https://api.github.com/users/gogainda/gists{/gist_id}","starred_url":"https://api.github.com/users/gogainda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogainda/subscriptions","organizations_url":"https://api.github.com/users/gogainda/orgs","repos_url":"https://api.github.com/users/gogainda/repos","events_url":"https://api.github.com/users/gogainda/events{/privacy}","received_events_url":"https://api.github.com/users/gogainda/received_events","type":"User","site_admin":false},"created_at":"2016-02-18T09:52:21Z","updated_at":"2016-02-18T09:52:21Z","body":"Seems you are right, I made a string out of Set aggregateIds and used it as a key. The speed of retrieving a value from cache reduced to roughly 0 or 1 ms"}}