Please sign in to comment.
Virtual Host: File Descriptor Table (FDT).
The File Descriptor Table (FDT) aims to provide a mechanism to share open file descriptors at Virtual Host level with the goal of to reduce the number of open file descriptors and reduce the calls to open(2) and close(2). The FDT is implemented in the following way: - For each worker thread, maintain a list matching the global Virtual Host list and for each entry create a Hash Table (HT) of 64 entries, and each HT entry maintain a sub-array of 8 chains. - When a request for a static file arrives, use the new Virtual Host open/close wrappers, from the given parsed and processed URI generate a hash value and try to see if it exists in the HT, if it don't exist, just open the file directly and register the data into the chain for a possible future reuse. If the hash exists in some HT/Chain, obtain the opened file descriptor and increment the readers counter. - When the Monkey core do not longer needs the file descriptor, instruct the Virtual Host 'close' wrapper to perform the cleanup. If the resource/hash exists in the HT/Chain, decrement the readers counter, if counter reach zero, just perform an explicit close(2) as nobody is using it, if readers is greater than zero just return as the file descriptor is in use. If the resource do not exists in the HT, do a direct close(2). The good thing of this implementation is that exists at worker level, so there is no race conditions and is lock-free. Also collisions are reduced to zero using HashTable Chaining. The hashing algorithm in use MurmurHash 2. This implementation reduce the overhead under high concurrency sharing the file descriptor resources and making it more scalable. Signed-off-by: Eduardo Silva <email@example.com>
- Loading branch information...
Showing with 325 additions and 6 deletions.
Oops, something went wrong.