-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
IO read performance #28481
Comments
Also, should the |
Yes, That noinline should be replaced with a gc-preserve now. |
No, that’s there to guarantee the allocation. We can’t fix that (or enable general stack allocation) due to copy-stacks. |
Oh, right. Well that will be fixed pretty soon too. |
Is the BufferedStreams implementation OK though? I understand this should all get better soon, but I kind of need a non-allocating solution right now. |
FYI, I just put together https://github.com/tkoolen/FastIOBuffers.jl. |
@tkoolen came across the same problem, your package works well for me so far. It would be nice to have this level of performance by default. |
FYI, I just redid the performance comparisons in the FastIOBuffers.jl readme, and while
|
If that is the case, a PR to manually outline this would be welcome since it is a performance sensitive function. |
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)).
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)).
See #31814. |
Manually extract out a separate noinline _throw_not_readable function. Addresses #28481 (comment).
Manually extract out a separate noinline _throw_not_readable function. Addresses #28481 (comment). (cherry picked from commit 98b34fd)
I opened JuliaCI/BaseBenchmarks.jl#223 to track performance of reading a
Float64
from anIOBuffer
. This currently allocates.I thought that maybe this would be resolved in 0.7 (elimination of the allocation of the
Ref
here), but I guess that's being explicitly prevented by the@noinline
here.BufferedStreams.jl has this implementation, which doesn't allocate. Is something like this acceptable for Base as well? I don't think there are any issues with GC roots or alignment in this implementation, are there?
The text was updated successfully, but these errors were encountered: