{"action":"created","issue":{"url":"https://api.github.com/repos/erlang/otp/issues/1803","repository_url":"https://api.github.com/repos/erlang/otp","labels_url":"https://api.github.com/repos/erlang/otp/issues/1803/labels{/name}","comments_url":"https://api.github.com/repos/erlang/otp/issues/1803/comments","events_url":"https://api.github.com/repos/erlang/otp/issues/1803/events","html_url":"https://github.com/erlang/otp/pull/1803","id":318730473,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg0ODQyNzcw","number":1803,"title":"Optimize binary match from 10% up to 70x","user":{"login":"josevalim","id":9582,"node_id":"MDQ6VXNlcjk1ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/9582?v=4","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"labels":[{"id":356265674,"node_id":"MDU6TGFiZWwzNTYyNjU2NzQ=","url":"https://api.github.com/repos/erlang/otp/labels/enhancement","name":"enhancement","color":"ddddee","default":true},{"id":356263938,"node_id":"MDU6TGFiZWwzNTYyNjM5Mzg=","url":"https://api.github.com/repos/erlang/otp/labels/team:VM","name":"team:VM","color":"006b75","default":false}],"state":"open","locked":false,"assignee":{"login":"garazdawi","id":111762,"node_id":"MDQ6VXNlcjExMTc2Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/111762?v=4","gravatar_id":"","url":"https://api.github.com/users/garazdawi","html_url":"https://github.com/garazdawi","followers_url":"https://api.github.com/users/garazdawi/followers","following_url":"https://api.github.com/users/garazdawi/following{/other_user}","gists_url":"https://api.github.com/users/garazdawi/gists{/gist_id}","starred_url":"https://api.github.com/users/garazdawi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garazdawi/subscriptions","organizations_url":"https://api.github.com/users/garazdawi/orgs","repos_url":"https://api.github.com/users/garazdawi/repos","events_url":"https://api.github.com/users/garazdawi/events{/privacy}","received_events_url":"https://api.github.com/users/garazdawi/received_events","type":"User","site_admin":false},"assignees":[{"login":"garazdawi","id":111762,"node_id":"MDQ6VXNlcjExMTc2Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/111762?v=4","gravatar_id":"","url":"https://api.github.com/users/garazdawi","html_url":"https://github.com/garazdawi","followers_url":"https://api.github.com/users/garazdawi/followers","following_url":"https://api.github.com/users/garazdawi/following{/other_user}","gists_url":"https://api.github.com/users/garazdawi/gists{/gist_id}","starred_url":"https://api.github.com/users/garazdawi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garazdawi/subscriptions","organizations_url":"https://api.github.com/users/garazdawi/orgs","repos_url":"https://api.github.com/users/garazdawi/repos","events_url":"https://api.github.com/users/garazdawi/events{/privacy}","received_events_url":"https://api.github.com/users/garazdawi/received_events","type":"User","site_admin":false}],"milestone":null,"comments":20,"created_at":"2018-04-29T16:32:22Z","updated_at":"2018-06-04T06:29:46Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/erlang/otp/pulls/1803","html_url":"https://github.com/erlang/otp/pull/1803","diff_url":"https://github.com/erlang/otp/pull/1803.diff","patch_url":"https://github.com/erlang/otp/pull/1803.patch"},"body":"The idea is to use `memchr` on the first lookup for `binary:match/2` and also after every match on `binary:matches/2`.\r\n\r\nThis speeds up binary matching and binary splitting by 4x in some cases and by 70x in other scenarios (when the last character in the needle does not occur in the subject).\r\n\r\nThe reason to use memchr is that it is highly specialized in most modern operating systems, often implemented in assembly and using SIMD instructions.\r\n\r\nThe implementation uses the reduction count to figure out how many bytes should be read with memchr.\r\n\r\nHuge thanks to @k0kubun to pointing me towards SIMD and memchr. And thanks to @citizen428 for the pairing.\r\n\r\nPS: I know the OTP team is busy this week so feel free to let this sit for a while. :)"},"comment":{"url":"https://api.github.com/repos/erlang/otp/issues/comments/394247728","html_url":"https://github.com/erlang/otp/pull/1803#issuecomment-394247728","issue_url":"https://api.github.com/repos/erlang/otp/issues/1803","id":394247728,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDI0NzcyOA==","user":{"login":"garazdawi","id":111762,"node_id":"MDQ6VXNlcjExMTc2Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/111762?v=4","gravatar_id":"","url":"https://api.github.com/users/garazdawi","html_url":"https://github.com/garazdawi","followers_url":"https://api.github.com/users/garazdawi/followers","following_url":"https://api.github.com/users/garazdawi/following{/other_user}","gists_url":"https://api.github.com/users/garazdawi/gists{/gist_id}","starred_url":"https://api.github.com/users/garazdawi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garazdawi/subscriptions","organizations_url":"https://api.github.com/users/garazdawi/orgs","repos_url":"https://api.github.com/users/garazdawi/repos","events_url":"https://api.github.com/users/garazdawi/events{/privacy}","received_events_url":"https://api.github.com/users/garazdawi/received_events","type":"User","site_admin":false},"created_at":"2018-06-04T06:29:46Z","updated_at":"2018-06-04T06:29:46Z","author_association":"CONTRIBUTOR","body":"This is the stack-trace when it fails. This PR will not make it into OTP-21.0, so no rush in fixing it.\r\n\r\n```\r\nThread 1 (process 23829):\r\n#0  0xb7d9cb50 in memchr () from /lib/libc.so.6\r\n#1  0x082070bc in bm_find_all_non_overlapping (ctx=0xb5a3f098, haystack=0xb467fe68 \"3tC43jÅFx76yceOVÄJOn3Gj3Gt2NöTooKzVkT1q5KQot4SiADx7tZGXnSKNidJsbwnUmqMLYkbbQwqDlRIhFnf23KvIYJSWcY7zGnUWäwfk9AM8soVZhpHrS3jmuO3ö21VzMp8äLfDIÄåWågEhQLfmxrVInIz5köOwv79jl7xVKQuBkn8HkIWJoÖEXVZfCS4aNRUktÄÄ\"...) at beam/erl_bif_binary.c:911\r\n#2  0x082061d1 in do_binary_find (p=0xb71886a8, subject=3040654090, ctxp=0xb5a3f148, pat_bin=0xb467aa70, ctx_bin=0x0, res_term=0xb5a3f140) at beam/erl_bif_binary.c:1417\r\n#3  0x08208589 in binary_split (p=0xb71886a8, arg1=3040654090, arg2=3040826894, arg3=3071002713) at beam/erl_bif_binary.c:1581\r\n#4  0x080886ac in process_main (x_reg_array=0xb76000c0, f_reg_array=0xb7601100) at i686-pc-linux-gnu/opt/smp/beam_hot.h:310\r\n#5  0x08095f36 in sched_thread_func (vesdp=0xb6501900) at beam/erl_process.c:8355\r\n#6  0x082a210b in thr_wrapper (vtwd=0xbfa3b298) at pthread/ethread.c:118\r\n#7  0xb7e612ab in start_thread () from /lib/libpthread.so.0\r\n#8  0xb7df058e in clone () from /lib/libc.so.6```"}}
{"actor":{"display_login":"garazdawi"}}