Skip to content

Commit 3d9c147

Browse files
authored
Merge pull request #732 from IntersectMBO/jdral/remove-fcntl-nocache
Remove `blockio:fcntl-nocache` in favour of the `unix` package
2 parents 1bf5f11 + 826488b commit 3d9c147

File tree

8 files changed

+14
-134
lines changed

8 files changed

+14
-134
lines changed

bench/macro/lsm-tree-bench-lookups.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module Main ( main ) where
44

55
import Control.DeepSeq
6+
import Control.Exception (bracket)
67
import Control.Monad
78
import Control.Monad.Class.MonadST
89
import Control.Monad.Primitive
@@ -198,18 +199,18 @@ benchmarks !caching = withFS $ \hfs hbio -> do
198199
(x1 + x2, y1 + y2)
199200
_bprepLookups <-
200201
benchmark "benchPrepLookups"
201-
"Calculate batches of keys, and prepare lookups for each batch. This is roughly doing the same amount of work as benchIndexSearches. Net time/allocation is the result of subtracting the cost of benchGenKeyBatches."
202+
"Calculate batches of keys, and prepare lookups for each batch. This is roughly doing the same amount of work as benchBloomQueries and benchIndexSearches. Net time/allocation is the result of subtracting the cost of benchGenKeyBatches."
202203
(benchPrepLookups arenaManager blooms indexes handles keyRng0) benchmarkNumLookups
203204
bgenKeyBatches
204205
_blookupsIO <-
205206
benchmark "benchLookupsIO"
206207
"Calculate batches of keys, and perform disk lookups for each batch. This is roughly doing the same as benchPrepLookups, but also performing the disk I/O and resolving values. Net time/allocation is the result of subtracting the cost of benchGenKeyBatches."
207208
(\n -> do
208209
let wb_unused = WB.empty
209-
wbblobs_unused <- WBB.new hfs (FS.mkFsPath [])
210-
benchLookupsIO hbio arenaManager benchmarkResolveSerialisedValue
211-
wb_unused wbblobs_unused runs blooms indexes handles
212-
keyRng0 n)
210+
bracket (WBB.new hfs (FS.mkFsPath ["wbblobs_unused"])) releaseRef $ \wbblobs_unused ->
211+
benchLookupsIO hbio arenaManager benchmarkResolveSerialisedValue
212+
wb_unused wbblobs_unused runs blooms indexes handles
213+
keyRng0 n)
213214
benchmarkNumLookups
214215
bgenKeyBatches
215216
--TODO: consider adding benchmarks that also use the write buffer

blockio/blockio.cabal

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,15 @@ library
8282
if os(linux)
8383
hs-source-dirs: src-linux
8484
other-modules: System.FS.BlockIO.Internal
85-
build-depends:
86-
, blockio:fcntl-nocache
87-
, unix ^>=2.8
85+
build-depends: unix ^>=2.8.7
8886

8987
if !flag(serialblockio)
9088
other-modules: System.FS.BlockIO.Async
9189
build-depends: blockio-uring ^>=0.1
9290

9391
elif os(osx)
9492
hs-source-dirs: src-macos
95-
build-depends:
96-
, blockio:fcntl-nocache
97-
, unix ^>=2.8
98-
93+
build-depends: unix ^>=2.8.7
9994
other-modules: System.FS.BlockIO.Internal
10095

10196
elif os(windows)
@@ -106,24 +101,11 @@ library
106101
if flag(serialblockio)
107102
cpp-options: -DSERIALBLOCKIO
108103

109-
library fcntl-nocache
110-
import: language, warnings
111-
visibility: private
112-
hs-source-dirs: src-fcntl-nocache
113-
114-
if os(windows)
115-
buildable: False
116-
117-
exposed-modules: System.Posix.Fcntl.NoCache
118-
build-depends: base <5
119-
build-tool-depends: hsc2hs:hsc2hs
120-
121104
test-suite test
122105
import: language, warnings
123106
type: exitcode-stdio-1.0
124107
hs-source-dirs: test
125108
main-is: Main.hs
126-
other-modules: Test.System.Posix.Fcntl.NoCache
127109
build-depends:
128110
, async
129111
, base <5
@@ -138,9 +120,6 @@ test-suite test
138120
, temporary
139121
, vector
140122

141-
if !os(windows)
142-
build-depends: blockio:fcntl-nocache
143-
144123
ghc-options: -threaded
145124

146125
library sim

blockio/src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc

Lines changed: 0 additions & 47 deletions
This file was deleted.

blockio/src-linux/System/FS/BlockIO/Internal.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import System.FS.BlockIO.API (Advice (..), FileOffset, HasBlockIO,
1212
import System.FS.IO (HandleIO)
1313
import qualified System.FS.IO.Handle as FS
1414
import qualified System.Posix.Fcntl as Fcntl
15-
import qualified System.Posix.Fcntl.NoCache as Unix
1615
import qualified System.Posix.Files as Unix
1716
import qualified System.Posix.Unistd as Unix
1817

@@ -53,7 +52,7 @@ ioHasBlockIO hfs params =
5352

5453
hSetNoCache :: Handle HandleIO -> Bool -> IO ()
5554
hSetNoCache h b =
56-
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Unix.writeFcntlNoCache b)
55+
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Fcntl.fileSetCaching (not b))
5756

5857
hAdvise :: Handle HandleIO -> FileOffset -> FileOffset -> Advice -> IO ()
5958
hAdvise h off len advice = FS.withOpenHandle "hAdvise" (handleRaw h) $ \fd ->

blockio/src-macos/System/FS/BlockIO/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import System.FS.BlockIO.API (Advice (..), FileOffset, HasBlockIO,
1010
import qualified System.FS.BlockIO.Serial as Serial
1111
import System.FS.IO (HandleIO)
1212
import qualified System.FS.IO.Handle as FS
13-
import qualified System.Posix.Fcntl.NoCache as Unix
13+
import qualified System.Posix.Fcntl as Unix
1414
import qualified System.Posix.Files as Unix
1515
import qualified System.Posix.Unistd as Unix
1616

@@ -36,7 +36,7 @@ ioHasBlockIO hfs _params =
3636

3737
hSetNoCache :: Handle HandleIO -> Bool -> IO ()
3838
hSetNoCache h b =
39-
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Unix.writeFcntlNoCache b)
39+
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Unix.fileSetCaching (not b))
4040

4141
-- TODO: it is unclear if MacOS supports @posix_fadvise(2)@, and it's hard to
4242
-- check because there are no manual pages online. For now, it's just hardcoded

blockio/test/Main.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ import Test.Tasty
3333
import Test.Tasty.HUnit
3434
import Test.Tasty.QuickCheck (testProperty)
3535

36-
import qualified Test.System.Posix.Fcntl.NoCache
37-
3836
main :: IO ()
3937
main = defaultMain tests
4038

4139
tests :: TestTree
4240
tests = testGroup "blockio:test" [
43-
Test.System.Posix.Fcntl.NoCache.tests
44-
, testCase "example_initClose" example_initClose
41+
testCase "example_initClose" example_initClose
4542
, testCase "example_closeIsIdempotent" example_closeIsIdempotent
4643
, testProperty "prop_readWrite" prop_readWrite
4744
, testProperty "prop_submitToClosedCtx" prop_submitToClosedCtx

blockio/test/Test/System/Posix/Fcntl/NoCache.hs

Lines changed: 0 additions & 49 deletions
This file was deleted.

cabal.project.release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
index-state:
22
-- Bump this if you need newer packages from Hackage
3-
-- quickcheck-lockstep-0.7.0
4-
, hackage.haskell.org 2025-05-09T15:42:47Z
3+
-- unix-2.8.7.0
4+
, hackage.haskell.org 2025-05-10T14:12:28Z
55

66
packages:
77
.

0 commit comments

Comments
 (0)