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

Memory allocations regression in julia 1.9 for Tuple{String, String} #51824

Open
armdavtyan opened this issue Oct 23, 2023 · 2 comments
Open
Labels
performance Must go faster

Comments

@armdavtyan
Copy link

armdavtyan commented Oct 23, 2023

Hi there, I’ve come across a notable regression issue in Julia 1.9.3. Would anyone happen to have any insights on this?
Interestingly, the script below doesn’t allocate any memory in Julia 1.8.1, but it leads to 200.00k allocations: 6.104 MiB in Julia 1.9.3.
This seems to be fixed in 1.10-beta3.

function f(arr)
    s = 0
    for el in arr
        if el  ("1", "2")
            s+=1
        end
    end
    return s
end
a = string.(rand(Int, 100000));
@time f(a) # Compilation consumes the majority of the time.
@time f(a) # So, we need to run it a second time

I have investigated the problem and found that the reason for the allocations is the presence of ("1", "2"). To confirm this, you can run the second example.

function g(arr, arg)
    s = 0
    for el in arr
        if el  arg
            s+=1
        end
    end
    return s
end
a = string.(rand(Int, 100000));
b = ("1", "2")
@time g(a, b)
@time g(a, b) # In Julia 1.9.3, allocations will be reduced to 0.
@KristofferC
Copy link
Sponsor Member

Seems fixed on 1.10 at least.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 23, 2023

The fix was probably #51573

@brenhinkeller brenhinkeller added the performance Must go faster label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

4 participants