Move file locking into the RTS, fixing #629, #1109
authorSimon Marlow <simonmar@microsoft.com>
Tue, 20 Nov 2007 12:10:53 +0000 (12:10 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Tue, 20 Nov 2007 12:10:53 +0000 (12:10 +0000)
commita2f1d2e47191b7fe17798829a5483d71f611e64b
tree69a058ed8ace22693194fe97d20a2dcc5a8ba855
parent3cbd1dca8f8e1e714dffbbc377cf724e09372ad7
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).
GHC/Handle.hs
System/Posix/Internals.hs
base.cabal
cbits/lockFile.c [deleted file]
include/HsBase.h
include/lockFile.h [deleted file]