diff options
author | Simon Marlow <simonmar@microsoft.com> | 2007-11-20 14:08:59 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2007-11-20 14:08:59 +0000 |
commit | 1d026619ef5f098a0349ba2fa1b29d5697718bad (patch) | |
tree | e0151d4684e8647dbfd3203043ebc41a46f46631 /rts/RtsStartup.c | |
parent | f22f248b88346df835b25f03f8d3372c7bb87950 (diff) | |
download | haskell-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/RtsStartup.c')
-rw-r--r-- | rts/RtsStartup.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index cdb45c60f2..4f84468b0a 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -33,6 +33,7 @@ #include "RtsTypeable.h" #include "Stable.h" #include "Hpc.h" +#include "FileLock.h" #if defined(RTS_GTK_FRONTPANEL) #include "FrontPanel.h" @@ -238,6 +239,11 @@ hs_init(int *argc, char **argv[]) /* initialise the shared Typeable store */ initTypeableStore(); + /* initialise file locking, if necessary */ +#if !defined(mingw32_HOST_OS) + initFileLocking(); +#endif + #if defined(DEBUG) /* initialise thread label table (tso->char*) */ initThreadLabelTable(); @@ -462,6 +468,11 @@ hs_exit_(rtsBool wait_foreign) /* free shared Typeable store */ exitTypeableStore(); + /* free file locking tables, if necessary */ +#if !defined(mingw32_HOST_OS) + freeFileLocking(); +#endif + /* free the stable pointer table */ exitStablePtrTable(); |