{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/30455","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/30455/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/30455/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/30455/events","html_url":"https://github.com/JuliaLang/julia/issues/30455","id":392777299,"node_id":"MDU6SXNzdWUzOTI3NzcyOTk=","number":30455,"title":"Broadcasting with missings is slow","user":{"login":"cstjean","id":8622776,"node_id":"MDQ6VXNlcjg2MjI3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/8622776?v=4","gravatar_id":"","url":"https://api.github.com/users/cstjean","html_url":"https://github.com/cstjean","followers_url":"https://api.github.com/users/cstjean/followers","following_url":"https://api.github.com/users/cstjean/following{/other_user}","gists_url":"https://api.github.com/users/cstjean/gists{/gist_id}","starred_url":"https://api.github.com/users/cstjean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cstjean/subscriptions","organizations_url":"https://api.github.com/users/cstjean/orgs","repos_url":"https://api.github.com/users/cstjean/repos","events_url":"https://api.github.com/users/cstjean/events{/privacy}","received_events_url":"https://api.github.com/users/cstjean/received_events","type":"User","site_admin":false},"labels":[{"id":418435319,"node_id":"MDU6TGFiZWw0MTg0MzUzMTk=","url":"https://api.github.com/repos/JuliaLang/julia/labels/broadcast","name":"broadcast","color":"1d76db","default":false},{"id":437820724,"node_id":"MDU6TGFiZWw0Mzc4MjA3MjQ=","url":"https://api.github.com/repos/JuliaLang/julia/labels/missing%20data","name":"missing data","color":"d4c5f9","default":false},{"id":115858,"node_id":"MDU6TGFiZWwxMTU4NTg=","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":4,"created_at":"2018-12-19T21:05:41Z","updated_at":"2018-12-21T12:59:41Z","closed_at":null,"author_association":"NONE","body":"This might just be #28126, but it looks like a separate problem. On 1.0.2:\r\n\r\n```julia\r\njulia> using BenchmarkTools\r\n\r\njulia> v = fill(2.0, 50000);\r\n\r\njulia> v2 = vcat(v, missing);\r\n\r\njulia> v3 = vcat(missing, v);\r\n\r\njulia> @btime $v .* 3.0;\r\n  33.105 μs (2 allocations: 390.70 KiB)\r\n\r\njulia> @btime $v2 .* 3.0;\r\n  1.610 ms (99498 allocations: 2.33 MiB)\r\n\r\njulia> @btime $v3 .* 3.0;\r\n  3.867 ms (7 allocations: 439.77 KiB)\r\n```\r\n\r\nApart from the 40X performance difference, two things stand out:\r\n\r\n- 99498 allocations for `v2`. Why? \r\n- Why is `v3` slower than `v2`, in spite of allocating much less?"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/449382305","html_url":"https://github.com/JuliaLang/julia/issues/30455#issuecomment-449382305","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/30455","id":449382305,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTM4MjMwNQ==","user":{"login":"nalimilan","id":1120448,"node_id":"MDQ6VXNlcjExMjA0NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/1120448?v=4","gravatar_id":"","url":"https://api.github.com/users/nalimilan","html_url":"https://github.com/nalimilan","followers_url":"https://api.github.com/users/nalimilan/followers","following_url":"https://api.github.com/users/nalimilan/following{/other_user}","gists_url":"https://api.github.com/users/nalimilan/gists{/gist_id}","starred_url":"https://api.github.com/users/nalimilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nalimilan/subscriptions","organizations_url":"https://api.github.com/users/nalimilan/orgs","repos_url":"https://api.github.com/users/nalimilan/repos","events_url":"https://api.github.com/users/nalimilan/events{/privacy}","received_events_url":"https://api.github.com/users/nalimilan/received_events","type":"User","site_admin":false},"created_at":"2018-12-21T12:59:41Z","updated_at":"2018-12-21T12:59:41Z","author_association":"CONTRIBUTOR","body":"Right, that's a different issue. Actually, the reason why `v2` allocates a lot is that it starts with a `Vector{Foat64}`, and when it encounters the last element (`missing`), it copies everything to a `Vector{Union{Missing,Float64}}`. Since that's the worst case, that's not necessarily a major issue: in practice the first `missing` should appear much earlier. Though it would be nice to avoid copying, see https://github.com/JuliaLang/julia/issues/26681.\r\n\r\nWhat's more problematic is that `v2` is slow, to the point that copying the whole vector (as happens for `v3`) is still faster than working with `Union{Missing,Float64}` from the beginning. I've tracked this down to the use of `typeof(val) <: T` instead of `val isa T` in `copyto_nonleaf!`. See https://github.com/JuliaLang/julia/pull/30480."}}
{"actor":{"display_login":"nalimilan"}}