{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/20054","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/20054/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/20054/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/20054/events","html_url":"https://github.com/JuliaLang/julia/issues/20054","id":200898742,"number":20054,"title":"mapreduce is slow","user":{"login":"mfiano","id":69571,"avatar_url":"https://avatars.githubusercontent.com/u/69571?v=3","gravatar_id":"","url":"https://api.github.com/users/mfiano","html_url":"https://github.com/mfiano","followers_url":"https://api.github.com/users/mfiano/followers","following_url":"https://api.github.com/users/mfiano/following{/other_user}","gists_url":"https://api.github.com/users/mfiano/gists{/gist_id}","starred_url":"https://api.github.com/users/mfiano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfiano/subscriptions","organizations_url":"https://api.github.com/users/mfiano/orgs","repos_url":"https://api.github.com/users/mfiano/repos","events_url":"https://api.github.com/users/mfiano/events{/privacy}","received_events_url":"https://api.github.com/users/mfiano/received_events","type":"User","site_admin":false},"labels":[{"id":115858,"url":"https://api.github.com/repos/JuliaLang/julia/labels/performance","name":"performance","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-15T22:07:53Z","updated_at":"2017-01-16T16:34:53Z","closed_at":null,"body":"New Julia user here. I am experiencing a big performance difference when using `@parallel` with 1 local worker:\r\n\r\n`@parallel` with 1 worker is much faster than `sum` or `reduce` for the following:\r\n\r\n```jl\r\njulia> procs()\r\n1-element Array{Int64,1}:\r\n 1\r\n\r\njulia> @time @parallel (+) for i=1:10^9; Int(rand(Bool)); end\r\n  2.580536 seconds (22.17 k allocations: 949.911 KB)\r\n499995637\r\n\r\njulia> @time sum(Int(rand(Bool)) for i in 1:10^9)\r\n  5.451454 seconds (18.49 k allocations: 789.608 KB)\r\n499973861\r\n\r\njulia> @time reduce(+, Int(rand(Bool)) for i in 1:10^9)\r\n  5.345948 seconds (33.21 k allocations: 1.368 MB)\r\n500021264\r\n\r\njulia> versioninfo()\r\nJulia Version 0.5.0\r\nCommit 3c9d753 (2016-09-19 18:14 UTC)\r\nPlatform Info:\r\n  System: Linux (x86_64-pc-linux-gnu)\r\n  CPU: Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz\r\n  WORD_SIZE: 64\r\n  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Sandybridge)\r\n  LAPACK: libopenblas\r\n  LIBM: libm\r\n  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)\r\n```"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/272908719","html_url":"https://github.com/JuliaLang/julia/issues/20054#issuecomment-272908719","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/20054","id":272908719,"user":{"login":"martinholters","id":15785210,"avatar_url":"https://avatars.githubusercontent.com/u/15785210?v=3","gravatar_id":"","url":"https://api.github.com/users/martinholters","html_url":"https://github.com/martinholters","followers_url":"https://api.github.com/users/martinholters/followers","following_url":"https://api.github.com/users/martinholters/following{/other_user}","gists_url":"https://api.github.com/users/martinholters/gists{/gist_id}","starred_url":"https://api.github.com/users/martinholters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinholters/subscriptions","organizations_url":"https://api.github.com/users/martinholters/orgs","repos_url":"https://api.github.com/users/martinholters/repos","events_url":"https://api.github.com/users/martinholters/events{/privacy}","received_events_url":"https://api.github.com/users/martinholters/received_events","type":"User","site_admin":false},"created_at":"2017-01-16T16:34:53Z","updated_at":"2017-01-16T16:34:53Z","body":"Observation: Most of the allocations are due to the anonymous function in global scope, but this has little effect on timing:\r\n```julia\r\njulia> @time reduce(+, Int(rand(Bool)) for i in 1:10^9) # after warm up\r\n  4.376660 seconds (32.98 k allocations: 1.355 MB)\r\n499991230\r\n\r\njulia> foo() = reduce(+, Int(rand(Bool)) for i in 1:10^9)\r\nfoo (generic function with 1 method)\r\n\r\njulia> @time foo()  # after warm up (omitted)\r\n  4.435923 seconds (7 allocations: 240 bytes)\r\n499992854\r\n```\r\n(Similar behavior on 0.5 and master.)"}}
{"actor":{"display_login":"martinholters"}}