Skip to content

Conversation

@aviatesk
Copy link
Member

Most of these conditions were introduced in #25828 and #30480 for some
performance reasons atm, but now they seem just unnecessary or even
harmful in terms of inferrability.

There doesn't seem to be any performance difference in the benchmark
used at #25828:

using BenchmarkTools
x = rand(Int, 100_000);
y = convert(Vector{Union{Int,Missing}}, x);
z = copy(y); z[2] = missing;

master:

julia> @btime map(identity, x);
  57.814 μs (3 allocations: 781.31 KiB)

julia> @btime map(identity, y);
  94.040 μs (3 allocations: 781.31 KiB)

julia> @btime map(identity, z);
  127.554 μs (5 allocations: 1.62 MiB)

julia> @btime broadcast(x->x, x);
  59.248 μs (2 allocations: 781.30 KiB)

julia> @btime broadcast(x->x, y);
  74.693 μs (2 allocations: 781.30 KiB)

julia> @btime broadcast(x->x, z);
  126.262 μs (4 allocations: 1.62 MiB)

this commit:

julia> @btime map(identity, x);
  58.668 μs (3 allocations: 781.31 KiB)

julia> @btime map(identity, y);
  94.013 μs (3 allocations: 781.31 KiB)

julia> @btime map(identity, z);
  126.600 μs (5 allocations: 1.62 MiB)

julia> @btime broadcast(x->x, x);
  57.531 μs (2 allocations: 781.30 KiB)

julia> @btime broadcast(x->x, y);
  69.561 μs (2 allocations: 781.30 KiB)

julia> @btime broadcast(x->x, z);
  125.578 μs (4 allocations: 1.62 MiB)

@nanosoldier runbenchmarks("union", vs=":master")

Most of these conditions were introduced in #25828 and #30480 for some
performance reasons atm, but now they seem just unnecessary or even
harmful in terms of inferrability.

There doesn't seem to be any performance difference in the benchmark
used at #25828:
```julia
using BenchmarkTools
x = rand(Int, 100_000);
y = convert(Vector{Union{Int,Missing}}, x);
z = copy(y); z[2] = missing;
```

> master:
```julia
julia> @Btime map(identity, x);
  57.814 μs (3 allocations: 781.31 KiB)

julia> @Btime map(identity, y);
  94.040 μs (3 allocations: 781.31 KiB)

julia> @Btime map(identity, z);
  127.554 μs (5 allocations: 1.62 MiB)

julia> @Btime broadcast(x->x, x);
  59.248 μs (2 allocations: 781.30 KiB)

julia> @Btime broadcast(x->x, y);
  74.693 μs (2 allocations: 781.30 KiB)

julia> @Btime broadcast(x->x, z);
  126.262 μs (4 allocations: 1.62 MiB)
```

> this commit:
```
julia> @Btime map(identity, x);
  58.668 μs (3 allocations: 781.31 KiB)

julia> @Btime map(identity, y);
  94.013 μs (3 allocations: 781.31 KiB)

julia> @Btime map(identity, z);
  126.600 μs (5 allocations: 1.62 MiB)

julia> @Btime broadcast(x->x, x);
  57.531 μs (2 allocations: 781.30 KiB)

julia> @Btime broadcast(x->x, y);
  69.561 μs (2 allocations: 781.30 KiB)

julia> @Btime broadcast(x->x, z);
  125.578 μs (4 allocations: 1.62 MiB)
```
@aviatesk aviatesk requested a review from nalimilan April 18, 2022 08:13
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@nalimilan
Copy link
Member

TBH I don't know why these were needed in the first place, so what matters is that benchmarks show they are no longer needed. Can you also check when there are e.g. 25-50% of missing values just in case?

@nalimilan nalimilan requested a review from vtjnash April 18, 2022 09:02
@aviatesk
Copy link
Member Author

Can you also check when there are e.g. 25-50% of missing values just in case?

Confirmed there seems to be no difference.

@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Apr 18, 2022
@JeffBezanson
Copy link
Member

This is great. I don't quite remember why these were once necessary, but i'm very glad they're not anymore!

@aviatesk aviatesk merged commit b15dab9 into master Apr 19, 2022
@aviatesk aviatesk deleted the avi/rmtypeof branch April 19, 2022 01:49
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants