Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closure on parametric isbits instance allocates a lot #21634

Closed
cstjean opened this issue Apr 29, 2017 · 1 comment
Closed

Closure on parametric isbits instance allocates a lot #21634

cstjean opened this issue Apr 29, 2017 · 1 comment

Comments

@cstjean
Copy link
Contributor

cstjean commented Apr 29, 2017

My code uses large parametric types, and I've found that making types more parametric can make everything 2X slower (excluding compilation time). Here's a 500X slowdown MWE:

# Julia Version 0.6.0-pre.beta.353
using BenchmarkTools

struct param{C}
    c::C
end

@noinline foo(x, flag) = x

function bar(x, flag)
    map() do
        rec() = foo(x, flag)
        rec()
    end
end
c = (1, (1, (((), (((1, (1, Val{:a}())), 1), 1)), 1)))

@btime bar(param(c), true)
> 5.523 μs (14 allocations: 800 bytes)
@btime bar(param{Any}(c), true);
> 9.136 ns (1 allocation: 16 bytes)

As far as I could tell, all of those parentheses are necessary.

@cstjean
Copy link
Contributor Author

cstjean commented Apr 29, 2017

It seems that most of the allocations come from dispatching on non-const globals, and returning a large value to the REPL; sorry for the noise.

@cstjean cstjean closed this as completed Apr 29, 2017
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

No branches or pull requests

1 participant