{"action":"created","issue":{"url":"https://api.github.com/repos/lemire/RoaringBitmap/issues/34","labels_url":"https://api.github.com/repos/lemire/RoaringBitmap/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/lemire/RoaringBitmap/issues/34/comments","events_url":"https://api.github.com/repos/lemire/RoaringBitmap/issues/34/events","html_url":"https://github.com/lemire/RoaringBitmap/issues/34","id":94604396,"number":34,"title":"10-15x performance opportunity for ImmutableRoaringBitmap","user":{"login":"krisskross","id":414023,"avatar_url":"https://avatars.githubusercontent.com/u/414023?v=3","gravatar_id":"","url":"https://api.github.com/users/krisskross","html_url":"https://github.com/krisskross","followers_url":"https://api.github.com/users/krisskross/followers","following_url":"https://api.github.com/users/krisskross/following{/other_user}","gists_url":"https://api.github.com/users/krisskross/gists{/gist_id}","starred_url":"https://api.github.com/users/krisskross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krisskross/subscriptions","organizations_url":"https://api.github.com/users/krisskross/orgs","repos_url":"https://api.github.com/users/krisskross/repos","events_url":"https://api.github.com/users/krisskross/events{/privacy}","received_events_url":"https://api.github.com/users/krisskross/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lemire/RoaringBitmap/labels/performance","name":"performance","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-07-12T22:15:43Z","updated_at":"2015-08-19T06:15:53Z","closed_at":"2015-08-18T20:13:45Z","body":"Hi\r\n\r\nI noticed that RoaringBitmap is several thousands times faster than ImmutableRoaringBitmap and got curious as to why this is. \r\n\r\nI wrote a few JMH tests and ran them in mission control and so far I managed to increase the speed by 10-15x by doing the following.\r\n\r\n1) Skip the clone in MutableRoaringArray.appendCopy.\r\n\r\n2) buffer.asShortBuffer().slice() in ImmutableRoaringArray.getContainerAtIndex steals a lot of performance. Things speed up quite a lot by creating ShortBuffer once and providing it to getContainerAtIndex instead. \r\n\r\nThe slice also steal performance but that requires a bigger change I suppose. I cannot prove it but I suspect that a regular ByteBuffer might be faster. Or even better, using Martin Thompson's [DirectBuffer](https://github.com/real-logic/Agrona/blob/master/src/main/java/uk/co/real_logic/agrona/concurrent/UnsafeBuffer.java).\r\n\r\nSince i'm unfamiliar with the code i'm not sure if these changes breaks some internals? Seems workable from the tests I made.\r\n\r\nCheers,\r\n-Kristoffer\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lemire/RoaringBitmap/issues/comments/132458636","html_url":"https://github.com/lemire/RoaringBitmap/issues/34#issuecomment-132458636","issue_url":"https://api.github.com/repos/lemire/RoaringBitmap/issues/34","id":132458636,"user":{"login":"krisskross","id":414023,"avatar_url":"https://avatars.githubusercontent.com/u/414023?v=3","gravatar_id":"","url":"https://api.github.com/users/krisskross","html_url":"https://github.com/krisskross","followers_url":"https://api.github.com/users/krisskross/followers","following_url":"https://api.github.com/users/krisskross/following{/other_user}","gists_url":"https://api.github.com/users/krisskross/gists{/gist_id}","starred_url":"https://api.github.com/users/krisskross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krisskross/subscriptions","organizations_url":"https://api.github.com/users/krisskross/orgs","repos_url":"https://api.github.com/users/krisskross/repos","events_url":"https://api.github.com/users/krisskross/events{/privacy}","received_events_url":"https://api.github.com/users/krisskross/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T06:15:53Z","updated_at":"2015-08-19T06:15:53Z","body":"I found it very useful to run jmc with jmh and output a file that can inspected after the test is done.\r\n\r\n```bash\r\njava -jar target/benchmarks.jar org.TestClass -jvmArgs=\"-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=60s,filename=file.jfr\"\r\n```"}}