{"action":"closed","issue":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2320","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2320/labels{/name}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2320/comments","events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2320/events","html_url":"https://github.com/cockroachdb/cockroach/issues/2320","id":104279648,"number":2320,"title":"Performance optimization：need add cache for Raft truncated state","user":{"login":"thundercw","id":11734583,"avatar_url":"https://avatars.githubusercontent.com/u/11734583?v=3","gravatar_id":"","url":"https://api.github.com/users/thundercw","html_url":"https://github.com/thundercw","followers_url":"https://api.github.com/users/thundercw/followers","following_url":"https://api.github.com/users/thundercw/following{/other_user}","gists_url":"https://api.github.com/users/thundercw/gists{/gist_id}","starred_url":"https://api.github.com/users/thundercw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thundercw/subscriptions","organizations_url":"https://api.github.com/users/thundercw/orgs","repos_url":"https://api.github.com/users/thundercw/repos","events_url":"https://api.github.com/users/thundercw/events{/privacy}","received_events_url":"https://api.github.com/users/thundercw/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T14:31:54Z","updated_at":"2015-09-21T21:14:32Z","closed_at":"2015-09-21T21:14:32Z","body":"We did a performance test and found that  `r.raftTruncatedState()`  is a performance bottleneck.\r\nSee call stacks:\r\n```\r\nstack1: multinode.go:run -> node.go:newReady()->r.raftLog.nextEnts()->l.slice()->mustCheckOutOfBounds()\r\n->l.firstIndex()->l.storage.FirstIndex()->raftTruncatedState()\r\nstack2: r.raftLog.term()->l.firstIndex()->l.storage.FirstIndex() ->raftTruncatedState\r\n```\r\nIf there is a lot of ranges and  write requests are heavy， It will become a bottleneck ."}}