On Tuesday, June 9, 2020 at 4:05:38 PM UTC+2, Amit Lavon wrote:
>
> I am reading raw bytes from a gzip input. I found that it only reads up to 
> chunks of 2^15 even though there is more data to be read.
>
> Is that the intended behavior? I expected whatever internal buffering it 
> may have to be invisible to the caller. If that's intended, how could I 
> have anticipated that? The contract of Reader 
> <https://golang.org/pkg/io/#Reader> says "Read conventionally returns 
> what is available instead of waiting for more" but it doesn't seem to be 
> the case here.
>
We're at the mercy of what the filesystem prefers to give us, and in my 
experience it likes many small chunks on any OS. I've seen consistent 
returns as low as 4k from plain file reading, so 32k from gzip 
decompression seems good. Behind the scenes the OS may already have 
buffered your entire file if it's not too huge, so I wouldn't worry about 
it being slower to loop through small buffers repeatedly.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/53405eec-3335-4f47-a503-594e9372a3f7o%40googlegroups.com.

Reply via email to