From 0e6178f9d79fd501eae060879ed38118b87ddf87 Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 23 Apr 2025 17:06:38 +0200 Subject: [PATCH] Extract a `blockio` package from `lsm-tree` --- blockio/CHANGELOG.md | 5 + blockio/LICENSE | 201 ++++++++++++++++++ blockio/NOTICE | 13 ++ blockio/README.md | 8 + blockio/blockio.cabal | 175 +++++++++++++++ .../System/Posix/Fcntl/NoCache.hsc | 0 .../src-linux/System/FS/BlockIO/Async.hs | 4 - .../src-linux/System/FS/BlockIO/Internal.hs | 0 .../src-macos/System/FS/BlockIO/Internal.hs | 0 .../src-sim}/System/FS/BlockIO/Sim.hs | 0 .../src-windows/System/FS/BlockIO/Internal.hs | 0 .../src/System/FS/BlockIO/API.hs | 10 +- .../src/System/FS/BlockIO/IO.hs | 0 .../src/System/FS/BlockIO/Serial.hs | 3 - .../test => blockio/test-sim}/Main.hs | 2 +- {blockio-api => blockio}/test/Main.hs | 10 +- .../test}/Test/System/Posix/Fcntl/NoCache.hs | 4 +- cabal.project.debug | 11 + cabal.project.release | 4 +- lsm-tree.cabal | 129 +---------- scripts/test-cabal-docspec.sh | 6 +- .../Database/LSMTree/Extras/NoThunks.hs | 2 +- test/Main.hs | 2 - 23 files changed, 437 insertions(+), 152 deletions(-) create mode 100644 blockio/CHANGELOG.md create mode 100644 blockio/LICENSE create mode 100644 blockio/NOTICE create mode 100644 blockio/README.md create mode 100644 blockio/blockio.cabal rename {src-fcntl-nocache => blockio/src-fcntl-nocache}/System/Posix/Fcntl/NoCache.hsc (100%) rename {blockio-api => blockio}/src-linux/System/FS/BlockIO/Async.hs (98%) rename {blockio-api => blockio}/src-linux/System/FS/BlockIO/Internal.hs (100%) rename {blockio-api => blockio}/src-macos/System/FS/BlockIO/Internal.hs (100%) rename {blockio-sim/src => blockio/src-sim}/System/FS/BlockIO/Sim.hs (100%) rename {blockio-api => blockio}/src-windows/System/FS/BlockIO/Internal.hs (100%) rename {blockio-api => blockio}/src/System/FS/BlockIO/API.hs (97%) rename {blockio-api => blockio}/src/System/FS/BlockIO/IO.hs (100%) rename {blockio-api => blockio}/src/System/FS/BlockIO/Serial.hs (98%) rename {blockio-sim/test => blockio/test-sim}/Main.hs (98%) rename {blockio-api => blockio}/test/Main.hs (97%) rename {test => blockio/test}/Test/System/Posix/Fcntl/NoCache.hs (92%) diff --git a/blockio/CHANGELOG.md b/blockio/CHANGELOG.md new file mode 100644 index 000000000..aeafb0082 --- /dev/null +++ b/blockio/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for blockio + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/blockio/LICENSE b/blockio/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/blockio/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/blockio/NOTICE b/blockio/NOTICE new file mode 100644 index 000000000..82751f478 --- /dev/null +++ b/blockio/NOTICE @@ -0,0 +1,13 @@ +Copyright 2023 Input Output Global, Inc. (IOG), 2023-2025 INTERSECT. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/blockio/README.md b/blockio/README.md new file mode 100644 index 000000000..e4ca4be2b --- /dev/null +++ b/blockio/README.md @@ -0,0 +1,8 @@ +# blockio + +This packages defines an abstract interface for batched, asynchronous I\/O, +for use with the abstract interface for file system I\/O defined by the +[fs-api](https://hackage.haskell.org/package/fs-api) package. + +The /sim/ sub-library of this package defines /simulated/ batched, asynchronous I\/O +for use with the [fs-sim](https://hackage.haskell.org/package/fs-sim) package. diff --git a/blockio/blockio.cabal b/blockio/blockio.cabal new file mode 100644 index 000000000..1b884add5 --- /dev/null +++ b/blockio/blockio.cabal @@ -0,0 +1,175 @@ +cabal-version: 3.4 +name: blockio +version: 0.1.0.0 +synopsis: Abstract interface for batched, asynchronous I/O +description: + This packages defines an abstract interface for batched, asynchronous I\/O, + for use with the abstract interface for file system I\/O defined by the + [fs-api](https://hackage.haskell.org/package/fs-api) package. + + The /sim/ sub-library of this package defines /simulated/ batched, asynchronous I\/O + for use with the [fs-sim](https://hackage.haskell.org/package/fs-sim) package. + +license: Apache-2.0 +license-files: + LICENSE + NOTICE + +author: + Duncan Coutts, Joris Dral, Matthias Heinzel, Wolfgang Jeltsch, Wen Kokke, and Alex Washburn + +maintainer: TODO: MAINTAINER EMAIL +copyright: + (c) 2023 Input Output Global, Inc. (IOG) + (c) 2023-2025 INTERSECT + +category: System +build-type: Simple +extra-doc-files: CHANGELOG.md +tested-with: GHC ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10 || ==9.12 + +source-repository head + type: git + location: https://github.com/IntersectMBO/lsm-tree + subdir: blockio + +-- TODO: this tag obviously does not exist yet because the package has not +-- been published +source-repository this + type: git + location: https://github.com/IntersectMBO/lsm-tree + tag: blockio-0.1.0.0 + subdir: blockio + +common warnings + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists + -Wno-unticked-promoted-constructors -Wunused-packages + + ghc-options: -Werror=missing-deriving-strategies + +common language + default-language: GHC2021 + default-extensions: + DeriveAnyClass + DerivingStrategies + DerivingVia + LambdaCase + +flag serialblockio + description: Use serial HasBlockIO regardless of the operating system + default: False + manual: True + +library + import: language, warnings + hs-source-dirs: src + exposed-modules: + System.FS.BlockIO.API + System.FS.BlockIO.IO + System.FS.BlockIO.Serial + + build-depends: + , base >=4.16 && <4.22 + , deepseq ^>=1.4 || ^>=1.5 + , fs-api ^>=0.3 + , io-classes ^>=1.6 || ^>=1.7 + , primitive ^>=0.9 + , vector ^>=0.13 + + if os(linux) + hs-source-dirs: src-linux + other-modules: System.FS.BlockIO.Internal + build-depends: + , blockio:fcntl-nocache + , unix ^>=2.8 + + if !flag(serialblockio) + other-modules: System.FS.BlockIO.Async + build-depends: blockio-uring ^>=0.1 + + elif os(osx) + hs-source-dirs: src-macos + build-depends: + , blockio:fcntl-nocache + , unix ^>=2.8 + + other-modules: System.FS.BlockIO.Internal + + elif os(windows) + hs-source-dirs: src-windows + build-depends: Win32 ^>=2.14 + other-modules: System.FS.BlockIO.Internal + + if flag(serialblockio) + cpp-options: -DSERIALBLOCKIO + +library fcntl-nocache + import: language, warnings + visibility: private + hs-source-dirs: src-fcntl-nocache + + if os(windows) + buildable: False + + exposed-modules: System.Posix.Fcntl.NoCache + build-depends: base <5 + build-tool-depends: hsc2hs:hsc2hs + +test-suite test + import: language, warnings + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Main.hs + other-modules: Test.System.Posix.Fcntl.NoCache + build-depends: + , async + , base <5 + , blockio + , bytestring + , fs-api + , primitive + , QuickCheck ^>=2.15.0.1 + , tasty + , tasty-hunit + , tasty-quickcheck + , temporary + , vector + + if !os(windows) + build-depends: blockio:fcntl-nocache + + ghc-options: -threaded + +library sim + import: language, warnings + visibility: public + hs-source-dirs: src-sim + exposed-modules: System.FS.BlockIO.Sim + build-depends: + , base >=4.16 && <4.22 + , blockio + , bytestring ^>=0.11.4.0 || ^>=0.12.1.0 + , fs-api ^>=0.3 + , fs-sim ^>=0.3 + , io-classes ^>=1.6 || ^>=1.7 + , io-classes:strict-stm + , primitive ^>=0.9 + +test-suite test-sim + import: language, warnings + type: exitcode-stdio-1.0 + hs-source-dirs: test-sim + main-is: Main.hs + build-depends: + , base <5 + , blockio + , blockio:sim + , fs-api + , fs-sim + , io-classes:strict-stm + , QuickCheck + , tasty + , tasty-quickcheck diff --git a/src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc b/blockio/src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc similarity index 100% rename from src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc rename to blockio/src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc diff --git a/blockio-api/src-linux/System/FS/BlockIO/Async.hs b/blockio/src-linux/System/FS/BlockIO/Async.hs similarity index 98% rename from blockio-api/src-linux/System/FS/BlockIO/Async.hs rename to blockio/src-linux/System/FS/BlockIO/Async.hs index 3edfc300d..5b5dc4a60 100644 --- a/blockio-api/src-linux/System/FS/BlockIO/Async.hs +++ b/blockio/src-linux/System/FS/BlockIO/Async.hs @@ -1,7 +1,3 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE ScopedTypeVariables #-} - module System.FS.BlockIO.Async ( asyncHasBlockIO ) where diff --git a/blockio-api/src-linux/System/FS/BlockIO/Internal.hs b/blockio/src-linux/System/FS/BlockIO/Internal.hs similarity index 100% rename from blockio-api/src-linux/System/FS/BlockIO/Internal.hs rename to blockio/src-linux/System/FS/BlockIO/Internal.hs diff --git a/blockio-api/src-macos/System/FS/BlockIO/Internal.hs b/blockio/src-macos/System/FS/BlockIO/Internal.hs similarity index 100% rename from blockio-api/src-macos/System/FS/BlockIO/Internal.hs rename to blockio/src-macos/System/FS/BlockIO/Internal.hs diff --git a/blockio-sim/src/System/FS/BlockIO/Sim.hs b/blockio/src-sim/System/FS/BlockIO/Sim.hs similarity index 100% rename from blockio-sim/src/System/FS/BlockIO/Sim.hs rename to blockio/src-sim/System/FS/BlockIO/Sim.hs diff --git a/blockio-api/src-windows/System/FS/BlockIO/Internal.hs b/blockio/src-windows/System/FS/BlockIO/Internal.hs similarity index 100% rename from blockio-api/src-windows/System/FS/BlockIO/Internal.hs rename to blockio/src-windows/System/FS/BlockIO/Internal.hs diff --git a/blockio-api/src/System/FS/BlockIO/API.hs b/blockio/src/System/FS/BlockIO/API.hs similarity index 97% rename from blockio-api/src/System/FS/BlockIO/API.hs rename to blockio/src/System/FS/BlockIO/API.hs index 14626936c..8b9756959 100644 --- a/blockio-api/src/System/FS/BlockIO/API.hs +++ b/blockio/src/System/FS/BlockIO/API.hs @@ -1,11 +1,5 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DerivingVia #-} -{-# LANGUAGE GeneralisedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UnboxedTuples #-} module System.FS.BlockIO.API ( -- * HasBlockIO diff --git a/blockio-api/src/System/FS/BlockIO/IO.hs b/blockio/src/System/FS/BlockIO/IO.hs similarity index 100% rename from blockio-api/src/System/FS/BlockIO/IO.hs rename to blockio/src/System/FS/BlockIO/IO.hs diff --git a/blockio-api/src/System/FS/BlockIO/Serial.hs b/blockio/src/System/FS/BlockIO/Serial.hs similarity index 98% rename from blockio-api/src/System/FS/BlockIO/Serial.hs rename to blockio/src/System/FS/BlockIO/Serial.hs index 08f6c1914..8db4e56c4 100644 --- a/blockio-api/src/System/FS/BlockIO/Serial.hs +++ b/blockio/src/System/FS/BlockIO/Serial.hs @@ -1,6 +1,3 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE ScopedTypeVariables #-} - module System.FS.BlockIO.Serial ( serialHasBlockIO ) where diff --git a/blockio-sim/test/Main.hs b/blockio/test-sim/Main.hs similarity index 98% rename from blockio-sim/test/Main.hs rename to blockio/test-sim/Main.hs index 71ef816ce..f29221766 100644 --- a/blockio-sim/test/Main.hs +++ b/blockio/test-sim/Main.hs @@ -16,7 +16,7 @@ main :: IO () main = defaultMain tests tests :: TestTree -tests = testGroup "blockio-sim" [ +tests = testGroup "blockio:test-sim" [ testProperty "prop_tryLockFileTwice" prop_tryLockFileTwice ] diff --git a/blockio-api/test/Main.hs b/blockio/test/Main.hs similarity index 97% rename from blockio-api/test/Main.hs rename to blockio/test/Main.hs index fad32dee3..9640ea83e 100644 --- a/blockio-api/test/Main.hs +++ b/blockio/test/Main.hs @@ -1,6 +1,3 @@ -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} - {-# OPTIONS_GHC -Wno-orphans #-} module Main (main) where @@ -36,12 +33,15 @@ import Test.Tasty import Test.Tasty.HUnit import Test.Tasty.QuickCheck (testProperty) +import qualified Test.System.Posix.Fcntl.NoCache + main :: IO () main = defaultMain tests tests :: TestTree -tests = testGroup "blockio-api" [ - testCase "example_initClose" example_initClose +tests = testGroup "blockio:test" [ + Test.System.Posix.Fcntl.NoCache.tests + , testCase "example_initClose" example_initClose , testCase "example_closeIsIdempotent" example_closeIsIdempotent , testProperty "prop_readWrite" prop_readWrite , testProperty "prop_submitToClosedCtx" prop_submitToClosedCtx diff --git a/test/Test/System/Posix/Fcntl/NoCache.hs b/blockio/test/Test/System/Posix/Fcntl/NoCache.hs similarity index 92% rename from test/Test/System/Posix/Fcntl/NoCache.hs rename to blockio/test/Test/System/Posix/Fcntl/NoCache.hs index 6f772a6bf..732d4d4a1 100644 --- a/test/Test/System/Posix/Fcntl/NoCache.hs +++ b/blockio/test/Test/System/Posix/Fcntl/NoCache.hs @@ -26,14 +26,14 @@ tests = testGroup "Test.System.Posix.Fcntl.NoCache" [] tests = testGroup "Test.System.Posix.Fcntl.NoCache" [ testCaseSteps "basic-read" $ \info -> do - withFile "lsm-tree.cabal" ReadMode $ \hdl -> do + withFile "blockio.cabal" ReadMode $ \hdl -> do GHC.FD {GHC.fdFD = fd} <- GHC.handleToFd hdl noCache <- readFcntlNoCache (Fd fd) info $ show noCache noCache @?= False , testCaseSteps "write-read" $ \info -> do - withFile "lsm-tree.cabal" ReadMode $ \hdl -> do + withFile "blockio.cabal" ReadMode $ \hdl -> do GHC.FD {GHC.fdFD = fd} <- GHC.handleToFd hdl writeFcntlNoCache (Fd fd) True noCache <- readFcntlNoCache (Fd fd) diff --git a/cabal.project.debug b/cabal.project.debug index ad72ae9a4..6a9ff1ee6 100644 --- a/cabal.project.debug +++ b/cabal.project.debug @@ -9,12 +9,23 @@ package lsm-tree -- there are no cpp-options in cabal.project files ghc-options: -optP -DNO_IGNORE_ASSERTS +package blockio + -- apply this to all components + -- relevant mostly only for development & testing + ghc-options: -fno-ignore-asserts + + -- there are no cpp-options in cabal.project files + ghc-options: -optP -DNO_IGNORE_ASSERTS + -- Enable -fcheck-prim-bounds -- https://gitlab.haskell.org/ghc/ghc/-/issues/21054 if impl(ghc >=9.4.6 && <9.5 || >=9.6.3) package lsm-tree ghc-options: -fcheck-prim-bounds + package blockio + ghc-options: -fcheck-prim-bounds + package primitive ghc-options: -fcheck-prim-bounds diff --git a/cabal.project.release b/cabal.project.release index 99c81e0a7..d86178ae4 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -3,7 +3,9 @@ index-state: -- current date: ghc-9.12 and data-elevator , hackage.haskell.org 2025-03-10T07:49:31Z -packages: . +packages: + . + ./blockio tests: True benchmarks: True diff --git a/lsm-tree.cabal b/lsm-tree.cabal index 1f3baa3fe..172b201c4 100644 --- a/lsm-tree.cabal +++ b/lsm-tree.cabal @@ -337,6 +337,7 @@ library build-depends: , base >=4.16 && <4.22 , bitvec ^>=1.1 + , blockio ^>=0.1 , bytestring ^>=0.11.4.0 || ^>=0.12.1.0 , cborg ^>=0.2.10.0 , containers ^>=0.6 || ^>=0.7 @@ -347,7 +348,6 @@ library , fs-api ^>=0.3 , io-classes ^>=1.6 || ^>=1.7 , io-classes:strict-mvar - , lsm-tree:blockio-api , lsm-tree:bloomfilter , lsm-tree:control , lsm-tree:kmerge @@ -484,6 +484,7 @@ library extras build-depends: , base >=4.16 && <4.22 , bitvec + , blockio , bytestring , containers , contra-tracer @@ -493,7 +494,6 @@ library extras , io-classes:strict-mvar , io-classes:strict-stm , lsm-tree - , lsm-tree:blockio-api , lsm-tree:bloomfilter , lsm-tree:control , lsm-tree:kmerge @@ -562,7 +562,6 @@ test-suite lsm-tree-test Test.Database.LSMTree.StateMachine.Op Test.Database.LSMTree.UnitTests Test.FS - Test.System.Posix.Fcntl.NoCache Test.Util.Arbitrary Test.Util.FS Test.Util.FS.Error @@ -578,6 +577,8 @@ test-suite lsm-tree-test , barbies , base <5 , bitvec + , blockio + , blockio:sim , bytestring , cborg , constraints @@ -595,8 +596,6 @@ test-suite lsm-tree-test , io-classes:strict-stm , io-sim , lsm-tree - , lsm-tree:blockio-api - , lsm-tree:blockio-sim , lsm-tree:bloomfilter , lsm-tree:control , lsm-tree:extras @@ -626,9 +625,6 @@ test-suite lsm-tree-test , vector-algorithms , wide-word - if !os(windows) - build-depends: lsm-tree:fcntl-nocache - ghc-options: -threaded benchmark lsm-tree-micro-bench @@ -649,6 +645,7 @@ benchmark lsm-tree-micro-bench build-depends: , base <5 + , blockio , bytestring , containers , contra-tracer @@ -657,7 +654,6 @@ benchmark lsm-tree-micro-bench , directory , fs-api , lsm-tree - , lsm-tree:blockio-api , lsm-tree:bloomfilter , lsm-tree:control , lsm-tree:extras @@ -692,11 +688,11 @@ benchmark lsm-tree-bench-lookups main-is: lsm-tree-bench-lookups.hs build-depends: , base <5 + , blockio , deepseq , fs-api , io-classes , lsm-tree - , lsm-tree:blockio-api , lsm-tree:bloomfilter , lsm-tree:control , lsm-tree:extras @@ -735,6 +731,7 @@ benchmark lsm-tree-bench-wp8 build-depends: , async , base <5 + , blockio , bytestring , clock , containers @@ -742,7 +739,6 @@ benchmark lsm-tree-bench-wp8 , deepseq , fs-api , lsm-tree - , lsm-tree:blockio-api , lsm-tree:extras , lsm-tree:mcg , optparse-applicative @@ -902,117 +898,6 @@ test-suite lsm-prototypes-tests , lsm-tree:prototypes , tasty -flag serialblockio - description: Use serial HasBlockIO regardless of the operating system - default: False - manual: True - -library blockio-api - import: language, warnings, wno-x-partial - visibility: private - hs-source-dirs: blockio-api/src - exposed-modules: - System.FS.BlockIO.API - System.FS.BlockIO.IO - System.FS.BlockIO.Serial - - build-depends: - , base >=4.16 && <4.22 - , deepseq ^>=1.4 || ^>=1.5 - , fs-api ^>=0.3 - , io-classes ^>=1.6 || ^>=1.7 - , primitive ^>=0.9 - , vector ^>=0.13 - - if os(linux) - hs-source-dirs: blockio-api/src-linux - other-modules: System.FS.BlockIO.Internal - build-depends: - , lsm-tree:fcntl-nocache - , unix ^>=2.8 - - if !flag(serialblockio) - other-modules: System.FS.BlockIO.Async - build-depends: blockio-uring ^>=0.1 - - elif os(osx) - hs-source-dirs: blockio-api/src-macos - build-depends: - , lsm-tree:fcntl-nocache - , unix ^>=2.8 - - other-modules: System.FS.BlockIO.Internal - - elif os(windows) - hs-source-dirs: blockio-api/src-windows - build-depends: Win32 ^>=2.14 - other-modules: System.FS.BlockIO.Internal - - if flag(serialblockio) - cpp-options: -DSERIALBLOCKIO - -test-suite blockio-api-test - import: language, warnings, wno-x-partial - type: exitcode-stdio-1.0 - hs-source-dirs: blockio-api/test - main-is: Main.hs - build-depends: - , async - , base >=4.16 && <4.22 - , bytestring - , fs-api - , lsm-tree:blockio-api - , primitive - , QuickCheck ^>=2.15.0.1 - , tasty - , tasty-hunit - , tasty-quickcheck - , temporary - , vector - - ghc-options: -threaded - -library blockio-sim - import: language, warnings, wno-x-partial - visibility: private - hs-source-dirs: blockio-sim/src - exposed-modules: System.FS.BlockIO.Sim - build-depends: - , base >=4.16 && <4.22 - , bytestring - , fs-api ^>=0.3 - , fs-sim ^>=0.3 - , io-classes ^>=1.6 || ^>=1.7 - , io-classes:strict-stm - , lsm-tree:blockio-api - , primitive ^>=0.9 - -test-suite blockio-sim-test - import: language, warnings - type: exitcode-stdio-1.0 - hs-source-dirs: blockio-sim/test - main-is: Main.hs - build-depends: - , base >=4.16 && <4.22 - , fs-api - , fs-sim - , io-classes:strict-stm - , lsm-tree:blockio-api - , lsm-tree:blockio-sim - , QuickCheck - , tasty - , tasty-quickcheck - -library fcntl-nocache - import: language, warnings - visibility: private - hs-source-dirs: src-fcntl-nocache - - if !os(windows) - exposed-modules: System.Posix.Fcntl.NoCache - build-depends: base <5 - build-tool-depends: hsc2hs:hsc2hs - library control import: language, warnings hs-source-dirs: src-control diff --git a/scripts/test-cabal-docspec.sh b/scripts/test-cabal-docspec.sh index f9290b8b8..9f6bf906b 100755 --- a/scripts/test-cabal-docspec.sh +++ b/scripts/test-cabal-docspec.sh @@ -3,7 +3,7 @@ export LC_ALL=C.UTF-8 # Check for cabal-docspec -cabal_docspec_required_version="0.0.0.20240414" +cabal_docspec_required_version="0.0.0.20240703" cabal_docspec="$(which cabal-docspec)" if [ "${cabal_docspec}" = "" ]; then echo "Requires cabal-docspec version ${cabal_docspec_required_version}; no version found" @@ -34,5 +34,5 @@ cabal-docspec \ -XInstanceSigs \ --extra-package directory \ --extra-package lsm-tree:prototypes \ - --extra-package lsm-tree:blockio-api \ - --extra-package lsm-tree:blockio-sim \ No newline at end of file + --extra-package blockio \ + --extra-package blockio:sim \ No newline at end of file diff --git a/src-extras/Database/LSMTree/Extras/NoThunks.hs b/src-extras/Database/LSMTree/Extras/NoThunks.hs index 0715fd142..b6e198be1 100644 --- a/src-extras/Database/LSMTree/Extras/NoThunks.hs +++ b/src-extras/Database/LSMTree/Extras/NoThunks.hs @@ -880,7 +880,7 @@ deriving via OnlyCheckWhnf FsPath instance NoThunks FsPath {------------------------------------------------------------------------------- - blockio-api and blockio-sim + blockio -------------------------------------------------------------------------------} -- TODO: check heap? diff --git a/test/Main.hs b/test/Main.hs index 283debc77..d3382bca2 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -46,7 +46,6 @@ import qualified Test.Database.LSMTree.StateMachine import qualified Test.Database.LSMTree.StateMachine.DL import qualified Test.Database.LSMTree.UnitTests import qualified Test.FS -import qualified Test.System.Posix.Fcntl.NoCache import Test.Tasty main :: IO () @@ -94,7 +93,6 @@ main = do , Test.Database.LSMTree.StateMachine.tests , Test.Database.LSMTree.StateMachine.DL.tests , Test.FS.tests - , Test.System.Posix.Fcntl.NoCache.tests ] Control.RefCount.checkForgottenRefs -- This use of checkForgottenRefs is a last resort. Refs that are forgotten