summaryrefslogtreecommitdiff
path: root/rts/Hash.c
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-11-20 14:08:59 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-11-20 14:08:59 +0000
commit1d026619ef5f098a0349ba2fa1b29d5697718bad (patch)
treee0151d4684e8647dbfd3203043ebc41a46f46631 /rts/Hash.c
parentf22f248b88346df835b25f03f8d3372c7bb87950 (diff)
downloadhaskell-1d026619ef5f098a0349ba2fa1b29d5697718bad.tar.gz
Move file locking into the RTS, fixing #629, #1109
File locking (of the Haskell 98 variety) was previously done using a static table with linear search, which had two problems: the array had a fixed size and was sometimes too small (#1109), and performance of lockFile/unlockFile was suboptimal due to the linear search. Also the algorithm failed to count readers as required by Haskell 98 (#629). Now it's done using a hash table (provided by the RTS). Furthermore I avoided the extra fstat() for every open file by passing the dev_t and ino_t into lockFile. This and the improvements to the locking algorithm result in a healthy 20% or so performance increase for opening/closing files (see openFile008 test).
Diffstat (limited to 'rts/Hash.c')
-rw-r--r--rts/Hash.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/rts/Hash.c b/rts/Hash.c
index 1d80640c4a..033ccb3e73 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -35,9 +35,6 @@ struct hashlist {
typedef struct hashlist HashList;
-typedef int HashFunction(HashTable *table, StgWord key);
-typedef int CompareFunction(StgWord key1, StgWord key2);
-
struct hashtable {
int split; /* Next bucket to split when expanding */
int max; /* Max bucket of smaller table */
@@ -55,7 +52,7 @@ struct hashtable {
* next bucket to be split, re-hash using the larger table.
* -------------------------------------------------------------------------- */
-static int
+int
hashWord(HashTable *table, StgWord key)
{
int bucket;
@@ -73,7 +70,7 @@ hashWord(HashTable *table, StgWord key)
return bucket;
}
-static int
+int
hashStr(HashTable *table, char *key)
{
int h, bucket;
@@ -347,7 +344,7 @@ freeHashTable(HashTable *table, void (*freeDataFun)(void *) )
* initializing all of the first segment's hash buckets to NULL.
* -------------------------------------------------------------------------- */
-static HashTable *
+HashTable *
allocHashTable_(HashFunction *hash, CompareFunction *compare)
{
HashTable *table;