Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.4", "9.8.2", "9.10.1"]
# TODO: Change "9.12.0.20241031" --> "9.12.1" after official release
ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.4", "9.8.2", "9.10.1", "9.12.0.20241031"]
cabal: ["3.10.2.1"]
os: [ubuntu-latest, windows-latest, macOS-latest]
cabal-flags: [""]
Expand Down Expand Up @@ -67,6 +68,8 @@ jobs:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: true
# TODO: remove once 9.12.1 is officially released
ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml

- name: Install liburing (on Linux)
id: setup-liburing
Expand Down
3 changes: 2 additions & 1 deletion cabal.project.debug
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ if impl(ghc >=9.4.6 && <9.5 || >=9.6.3)
ghc-options: -fcheck-prim-bounds

package fs-sim
ghc-options: -fcheck-prim-bounds
ghc-options: -fcheck-prim-bounds

3 changes: 3 additions & 0 deletions cabal.project.release
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ source-repository-package
type: git
location: https://github.com/well-typed/quickcheck-lockstep.git
tag: 1852cf87a76dc48c71aa0d9fda3fdc7c8b965011

if impl(ghc >=9.12)
allow-newer: base
22 changes: 11 additions & 11 deletions lsm-tree.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-type: Simple
extra-doc-files: CHANGELOG.md
extra-source-files: README.md
tested-with:
GHC ==8.10 || ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10
GHC ==8.10 || ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10 || ==9.12

source-repository head
type: git
Expand Down Expand Up @@ -166,7 +166,7 @@ library
Database.LSMTree.Normal

build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, bitvec ^>=1.1
, bytestring ^>=0.11.4.0 || ^>=0.12.1.0
, cborg ^>=0.2.10.0
Expand Down Expand Up @@ -311,7 +311,7 @@ library extras
Database.LSMTree.Extras.UTxO

build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, bitvec
, bytestring
, containers
Expand Down Expand Up @@ -640,7 +640,7 @@ test-suite kmerge-test
hs-source-dirs: test
main-is: kmerge-test.hs
build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, deepseq
, heaps
, lsm-tree:kmerge
Expand All @@ -659,7 +659,7 @@ benchmark kmerge-bench
main-is: kmerge-test.hs
cpp-options: -DKMERGE_BENCHMARKS
build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, deepseq
, heaps
, lsm-tree:kmerge
Expand All @@ -677,7 +677,7 @@ test-suite map-range-test
hs-source-dirs: test
main-is: map-range-test.hs
build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, bytestring
, containers
, lsm-tree
Expand Down Expand Up @@ -738,7 +738,7 @@ library blockio-api
System.FS.BlockIO.Serial

build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, deepseq ^>=1.4 || ^>=1.5
, fs-api ^>=0.3
, io-classes ^>=1.6 || ^>=1.7
Expand Down Expand Up @@ -775,7 +775,7 @@ test-suite blockio-api-test
main-is: Main.hs
build-depends:
, async
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, bytestring
, fs-api
, lsm-tree:blockio-api
Expand All @@ -795,7 +795,7 @@ library blockio-sim
hs-source-dirs: blockio-sim/src
exposed-modules: System.FS.BlockIO.Sim
build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, bytestring
, fs-api ^>=0.3
, fs-sim ^>=0.3
Expand All @@ -810,7 +810,7 @@ test-suite blockio-sim-test
hs-source-dirs: blockio-sim/test
main-is: Main.hs
build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, fs-api
, fs-sim
, io-classes:strict-stm
Expand Down Expand Up @@ -839,7 +839,7 @@ library control
Control.TempRegistry

build-depends:
, base >=4.14 && <4.21
, base >=4.14 && <4.22
, containers ^>=0.6 || ^>=0.7
, deepseq ^>=1.4 || ^>=1.5
, io-classes ^>=1.6 || ^>=1.7
Expand Down
36 changes: 31 additions & 5 deletions test/kmerge-test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Test.Tasty.QuickCheck (testProperty, (===))
import qualified KMerge.Heap as K.Heap
import qualified KMerge.LoserTree as K.Tree


-- tests and benchmarks for various k-way merge implementations.
-- in short: loser tree is optimal in comparison counts performed,
-- but mutable heap implementation has lower constant factors.
Expand Down Expand Up @@ -57,6 +58,7 @@ main = do
_ <- evaluate $ force input7
_ <- evaluate $ force input5


defaultMainWithIngredients B.benchIngredients $ testGroup "kmerge"
[ testGroup "tests"
[ testGroup "merge"
Expand All @@ -75,7 +77,7 @@ main = do
-- (because the input values are unformly random,
-- there shouldn't be a lot of "cheap" leftovers elements,
-- i.e. when other inputs are exhausted, but there are few)
[ testCount "sortConcat" 3190 (L.sort . concat) input8
[ testCount "sortConcat" comparisons8 (L.sort . concat) input8
, testCount "listMerge" 3479 listMerge input8
, testCount "treeMerge" 2391 treeMerge input8
, testCount "heapMerge" 3168 heapMerge input8
Expand Down Expand Up @@ -115,7 +117,7 @@ main = do
-- but I'm too lazy to think how to do that)
--
, testGroup "seven"
[ testCount "sortConcat" 2691 (L.sort . concat) input7
[ testCount "sortConcat" comparisons7 (L.sort . concat) input7
, testCount "listMerge" 2682 listMerge input7
, testCount "treeMerge" 1992 treeMerge input7
, testCount "heapMerge" 2645 heapMerge input7
Expand All @@ -126,7 +128,7 @@ main = do
-- and 2x100 with 3 comparisons.
-- i.e. target is 1200 total comparisons.
, testGroup "five"
[ testCount "sortConcat" 1790 (L.sort . concat) input5
[ testCount "sortConcat" comparisons5 (L.sort . concat) input5
, testCount "listMerge" 1389 listMerge input5
, testCount "treeMerge" 1291 treeMerge input5
, testCount "heapMerge" 1485 heapMerge input5
Expand All @@ -139,7 +141,7 @@ main = do
-- 4x125 elements with 3 comparisons
-- i.e. target is 2000 total comparisons.
, testGroup "levelling-min"
[ testCount "sortConcat" 3729 (L.sort . concat) inputLevellingMin
[ testCount "sortConcat" comparisonsMin (L.sort . concat) inputLevellingMin
, testCount "listMerge" 2112 listMerge inputLevellingMin
, testCount "treeMerge" 2730 treeMerge inputLevellingMin
, testCount "heapMerge" 2655 heapMerge inputLevellingMin
Expand All @@ -153,7 +155,7 @@ main = do
-- 4x 50 elements with 3 comparisons
-- i.e. target is 1400 total comparisons.
, testGroup "levelling-max"
[ testCount "sortConcat" 3872 (L.sort . concat) inputLevellingMax
[ testCount "sortConcat" comparisonsMax (L.sort . concat) inputLevellingMax
, testCount "listMerge" 1440 listMerge inputLevellingMax
, testCount "treeMerge" 2873 treeMerge inputLevellingMax
, testCount "heapMerge" 1784 heapMerge inputLevellingMax
Expand Down Expand Up @@ -440,3 +442,27 @@ mutHeapMerge xss = case [ Heap.Entry x xs | x : xs <- xss ] of
go !heap (Just (Heap.Entry x xs)) = fmap (x :) $ case xs of
[] -> K.Heap.extract heap >>= go heap
x':xs' -> K.Heap.replaceRoot heap (Heap.Entry x' xs') >>= go heap . Just

{-------------------------------------------------------------------------------
Account for differing sort comparisons across base versions
-------------------------------------------------------------------------------}

-- | The 'sort' and 'sortBy' implementations changed as of @base-4.21@.
-- The new implementation performs fewer comparisons on longer lists.
--
-- Because of this, we fall back to the old sort method when the version of
-- @base@ is @4.21@ or greater.
comparisons5, comparisons7, comparisons8, comparisonsMin, comparisonsMax :: Int
#if MIN_VERSION_base(4,21,0)
comparisons5 = 1692
comparisons7 = 2691
comparisons8 = 3389
comparisonsMin = 3606
comparisonsMax = 3820
#else
comparisons5 = 1790
comparisons7 = 2691
comparisons8 = 3190
comparisonsMin = 3729
comparisonsMax = 3872
#endif