In #89165 I updated Read::read_to_end to try to detect EOF when the input buffer is full by reading into a small "probe" buffer. If that read returns Ok(0) then it avoids unnecessarily doubling the capacity of the input buffer.
I think there'd be some value in trying to eliminate even the "probe buffer" call, but in the meantime, this seems like an improvement.
Originally posted by @joshtriplett in #89165 (comment)
Josh, did you have something in mind?
I thought a way: use read_vectored. I could add the probe buffer to a vectorized readv, which would eliminate the extra read syscall.
-
Is that idea worth pursuing?
-
Is it okay to simply switch the read call(s) to read_vectored, or would it be better to check is_read_vectored and have separate vectorized and non-vectorized code paths? I'm inclined to keep it simple and do the former.