bug-myserver
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-myserver] optimize file cache


From: Giuseppe Scrivano
Subject: Re: [bug-myserver] optimize file cache
Date: Wed, 01 Oct 2008 13:01:25 +0200
User-agent: Thunderbird 2.0.0.17 (Windows/20080914)

Hello,

such improvements can be added in the idle thread and must pay attention
to don't be executed while the server is not very busy (or you will end
to make it slower).  As it is a heuristical approach, I think it will be
good to have at least prototype and check its hits rate.

About files cache, a thing that must absolutely changed is to have
zero-copy on the socket.
 At the moment the cached file content is copied on another buffer and
from this buffer send on the socket, this can lead to have worst
performances than using sendfile or almost the same as using an usual
(read from file -> write to socket) loop.
I think there is need to refactor the File class to allow the usage of
sendfile, maybe adding a method like File::fastCopyToSocket (Socket*
socket, char* tmpBuffer); that is implemented by the cached file class
as a simple send on the socket object.  The tmpBuffer argument is dirty
but when sendfile is not available we can use one of the 2 big buffers
allocated for each thread.

Giuseppe


Daniele Perrone wrote:
> And just another email for you,
> Now I don't have the code here but I think that the way we use to
> cache files isn't so good. I understood that myserver at each request,
> if a file is not in memory and the cache limits are reached, load it
> in memory and then send it to the client. Then there are lucky
> clients, that find file they need in the cache, and unlucky clients,
> that have to wait for the loading of file in the memory first.
> What do you think if we use a statistic approach to load files in to
> the memory? Something like, if "file1" is requested at time 0, then at
> time 1 maybe  "file2" will be request (using statistical information
> we know this), therefor we can just load "file2" at time 0 after
> responding to the request.
> 
> I hope the idea is clear, I know, ti's just in an emobryonic state,
> but I think can be a good improvment in myserver performance.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]