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

allocate small strings in 8-byte-aligned pools #41247

Merged
merged 1 commit into from
Jun 18, 2021
Merged

Conversation

JeffBezanson
Copy link
Member

This is a less-disruptive alternative to #40727 that keeps the representation the same and just uses less alignment padding.

Before:

function example()
    for j = 1:20, i = 1:1_000_000
        string(i)
    end
end

julia> @btime example()
  598.121 ms (40000000 allocations: 1.79 GiB)

julia> @btime for i = 1:2^24
    "a"*"b"
end
  247.768 ms (16777216 allocations: 512.00 MiB)

after:

julia> @btime example()
  607.298 ms (40000000 allocations: 1.64 GiB)

julia> @btime for i = 1:2^24
    "a"*"b"
end
  247.473 ms (16777216 allocations: 384.00 MiB)

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

@JeffBezanson JeffBezanson added performance Must go faster strings "Strings!" labels Jun 16, 2021
@nanosoldier
Copy link
Collaborator

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

@JeffBezanson
Copy link
Member Author

JeffBezanson commented Jun 18, 2021

We discussed this a bit on triage. Seems like we agree it's a win-win. Plus we could use the new pools in the future for other objects with less-strict alignment, e.g. a struct of 9 bytes.

@JeffBezanson JeffBezanson merged commit fb67607 into master Jun 18, 2021
@JeffBezanson JeffBezanson deleted the jb/string8b branch June 18, 2021 18:17
@oscardssmith
Copy link
Member

If we're back-porting the change to array size to 1.7, do we want to back-port this too?

johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants