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

fix #28481, faster reading of primitive types from IOStream and IOBuffer #29186

Merged
merged 1 commit into from
Sep 17, 2018

Conversation

JeffBezanson
Copy link
Member

This adds a fast implementation of reading Base numeric types from an IOBuffer, and extends the existing method for IOStream to floats.

fix #28481

@JeffBezanson JeffBezanson added performance Must go faster io Involving the I/O subsystem: libuv, read, write, etc. backport pending 1.0 labels Sep 14, 2018
@andyferris
Copy link
Member

This is really nice to see. Any impressive benchmarks?

Also, is there some way to make this generic for bitstypes?

@JeffBezanson
Copy link
Member Author

JeffBezanson commented Sep 14, 2018

Here's a test case with a random ~22MB file. rd is a function that reads the whole file by repeatedly reading the given type. f is the file as an IOStream, b is the same data copied to an IOBuffer.
Before:

julia> @time rd(f, Float32)
  0.114615 seconds (5.72 M allocations: 87.302 MiB, 4.46% gc time)

julia> @time rd(b, Float32)
  0.079160 seconds (5.72 M allocations: 87.302 MiB, 3.16% gc time)

After:

julia> @time rd(f, Float32)
  0.073971 seconds (4 allocations: 160 bytes)

julia> @time rd(b, Float32)
  0.014330 seconds (4 allocations: 160 bytes)

@JeffBezanson JeffBezanson merged commit c0afddf into master Sep 17, 2018
@JeffBezanson JeffBezanson deleted the jb/fasternumread branch September 17, 2018 15:03
KristofferC pushed a commit that referenced this pull request Sep 17, 2018
@KristofferC KristofferC mentioned this pull request Sep 17, 2018
avail = bytesavailable(from)
nb = sizeof(T)
if nb > avail
throw(EOFError())
Copy link
Member

Choose a reason for hiding this comment

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

insert from.ptr += avail? Although I don't know how strict we are about this consuming data before errors.

KristofferC pushed a commit that referenced this pull request Feb 11, 2019
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.

IO read performance
4 participants