:: Re: [DNG] "Common knowledge?"-quest…
Kezdőlap
Delete this message
Reply to this message
Szerző: Rainer Weikusat
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] "Common knowledge?"-question
karl@??? writes:
> Rainer Weikusat:
>> karl@??? writes:
>> > Katola2:
>> > ...
>> >> void another_print_start(char *name, char *what){
>> >>
>> >> char c[3] = " :";
>> >>
>> >> c[2] = name[0] & ~0x20;
>> >>
>> >> write(2, c+2, 1);
>> >> write(2, name+1, strlen(name) -1);
>> >> write(2, c, 2);
>> >> write(2, what, strlen(what));
>> >>
>> >> }
>> >
>> > Why not just use writev(2) and write it one system call ?
>
> Since people complained about allocations, I thought you could use this
> and have a static struct iovec[4];, then the only allocations done
> would be for simple types.
>
>> The idea behind writev is to avoid userspace block memory copies
>> prior


[and unless the average block size is more than 2 times 16, this ends up
doing more copying instead of less]

> ...
>> that's 3 lines of code less which is "not great". In addition to this,
>> both write and writev may end up writing less data than requested and
>> the code for restarting a partially completed writev is more complicated
>> than the same for write.
>
> Both true.


The core of my statement was not about neligible code savings in one
place ending up as code increases in another but about causing
additional copying instead of avoiding it in case of small areas.