Why do you keep io->this in the struct? Is it to avoid accessing the global Pike_fp->current_object ?
On Wed, Sep 10, 2014 at 4:55 PM, Stephen R. van den Berg srb@cuci.nl wrote:
Why do you keep io->this in the struct? Is it to avoid accessing the global Pike_fp->current_object ?
Ah, partly, mainly it is however that the io-struct passed to the io_* functions is not always the Pike_fp->current_object object.
In IOBuffer.output_to(): Why use fd_write with smaller chunks than the maximum chunk we want to write?
Why use fd_write with smaller chunks than the maximum chunk we want to write?
Because the write(2) system call /copies/ the data to kernel space. (1)
It is _far_ faster to write small chunks (4k with page alignment would be optimal, really). (2)
Let's say that we have a 1Gb buffer. It's fairly likely the we can not write the whole thing at once to a nonblocking file, right? So, this way at most 4k is copied needlessly.
1) Not true in all cases. But as a simplification it is.
2) If the buffer was at all times page aligned 1 could be made untrue by using nice async_io linux extensions.
You can see a small discussion carried out in comments in file.c
pike-devel@lists.lysator.liu.se