Update fd_hash to use the fd itself as the hash value for performance, w/ G & E
This commit is contained in:
@@ -406,7 +406,12 @@ syscall_close (int fd)
|
|||||||
unsigned
|
unsigned
|
||||||
fd_hash (const struct hash_elem *element, void *aux UNUSED)
|
fd_hash (const struct hash_elem *element, void *aux UNUSED)
|
||||||
{
|
{
|
||||||
return hash_int (hash_entry (element, struct open_file, elem)->fd);
|
/* We use the FD as the hash value. This is because the FD is incremented
|
||||||
|
sequentially and is therefore unique for each file. It positively affects
|
||||||
|
the performance of the hash table: 1. It is unique so no need to call
|
||||||
|
expensive hash functions. 2. It being sequential means that the hash table
|
||||||
|
is more likely to be weight balanced. */
|
||||||
|
return hash_entry (element, struct open_file, elem)->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Comparator function for the open_file table. Compares two entries based on
|
/* Comparator function for the open_file table. Compares two entries based on
|
||||||
|
|||||||
Reference in New Issue
Block a user