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

Improve IO read performance. #31814

Merged
merged 1 commit into from
Apr 24, 2019

Conversation

tkoolen
Copy link
Contributor

@tkoolen tkoolen commented Apr 24, 2019

Manually extract out a separate noinline _throw_not_readable function.

Addresses #28481 (comment).

Benchmark scenario:

using BenchmarkTools, Random
const N = 1000
@btime read(buf, Float64) evals = N setup = begin
    rng = MersenneTwister(1)
    writebuf = IOBuffer()
    map(1 : N) do _
        write(writebuf, rand(rng, Float64))
    end
    buf = IOBuffer(take!(writebuf))
end

Benchmark results (CPU: Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz):

  • Before: 2.533 ns (0 allocations: 0 bytes)
  • After: 1.775 ns (0 allocations: 0 bytes)

Performance is now much closer to, but still not quite at the level of FastIOBuffers.FastReadBuffer (1.555 ns (0 allocations: 0 bytes)).

Manually extract out a separate noinline _throw_not_readable function.

Addresses
JuliaLang#28481 (comment).

Benchmark scenario:

```julia
using BenchmarkTools, Random
const N = 1000
@Btime read(buf, Float64) evals = N setup = begin
    rng = MersenneTwister(1)
    writebuf = IOBuffer()
    map(1 : N) do _
        write(writebuf, rand(rng, Float64))
    end
    buf = IOBuffer(take!(writebuf))
end
```

Benchmark results (CPU: Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz):

* Before: 2.533 ns (0 allocations: 0 bytes)
* After: 1.775 ns (0 allocations: 0 bytes)

Performance is now much closer to, but still not quite at the level of
FastIOBuffers.FastReadBuffer (1.555 ns (0 allocations: 0 bytes)).
@tkoolen tkoolen mentioned this pull request Apr 24, 2019
@JeffBezanson JeffBezanson added io Involving the I/O subsystem: libuv, read, write, etc. performance Must go faster labels Apr 24, 2019
Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s probably good to consolidate all these too

@fredrikekre fredrikekre merged commit 98b34fd into JuliaLang:master Apr 24, 2019
@tkoolen tkoolen deleted the tk/iobuffer-read-noinline branch April 24, 2019 13:08
KristofferC pushed a commit that referenced this pull request May 9, 2019
Manually extract out a separate noinline _throw_not_readable function.
Addresses #28481 (comment).

(cherry picked from commit 98b34fd)
@KristofferC KristofferC mentioned this pull request May 9, 2019
58 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc. performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants