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

Prevents premature EOFError on blocking reads #13632

Closed
wants to merge 0 commits into from

Conversation

hessammehr
Copy link
Contributor

(rebased) Blocks until the required number of bytes has been read. Only throws EOFError on actual EOF. Fixes #13559.

@pao
Copy link
Member

pao commented Oct 15, 2015

(Rebased version of #13620.)

@vtjnash
Copy link
Member

vtjnash commented Oct 15, 2015

i believe the previous version was designed to be quite significantly more efficient that this replacement. can you comment on the performance?

@tkelman
Copy link
Contributor

tkelman commented Oct 15, 2015

If the perf is okay with this version, should remove the unused C function.

@hessammehr
Copy link
Contributor Author

@vtjnash You are absolutely right.

function bench_readInt64()
       buf = Array{Int64}(100000)
       f = open("/dev/zero", "r")
       for i = 1:100000
              buf[i] = read(f, Int64)
       end
       close(f)
       return buf
end

Before this commit

@time bench_readInt64()
  0.004214 seconds (15 allocations: 782.016 KB)

After

  0.108966 seconds (500.01 k allocations: 31.281 MB, 8.91% gc time)

It seems like readbytes is responsible for some of the performance hit.

@time for i=1:100000 readbytes(a, 8, all=true) end
  0.062285 seconds (300.00 k allocations: 22.888 MB, 6.15% gc time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants