Sa Feb 06 2010 10:33:05 EST von IGnatius T Foobar @ Uncensored Betreff: Re: Citadel commit log: revision 8275
* use mmap to read the download file for output; this way we don't need to copy
it into memory first and can let the kernel do >this job Does mmap() read the whole file into memory at the kernel level? Or does it merely provide userspace with the illusion that this has happened? Obviously if there are big files out there we don't want to load the whole file image into main memory...
the kernel will do mmap() automagicaly in malloc if the desired size outdoes a certain ammount of memory.
mmap gives you the illusion of what you got on that pointer being memory, but its pointing to the disk.
since we're doing a linear read on it here, its probably the OS to choose what to cache.
we got two uses here:
* the static pictures and files which probably where on disk for quiet a while
* the temporary written attachment
so... why "read" it into memory if it can be done in place?
And... If citadel forces the os to use 4k buffers, how's one to know that this is what the kernel wants to send? Just pointing it to a blob and doing the select/write loop is the best whats to be done to give the kernel as much control over it as possible, which means less context switches -> faster