Skip to content

Commit 1fcd12d

Browse files
committed
merge linear-dest back into linear-base
1 parent a78d659 commit 1fcd12d

File tree

64 files changed

+203983
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+203983
-15
lines changed

.ghcid

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--command "cabal repl --enable-multi-repl"

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ghc*.tar.xz filter=lfs diff=lfs merge=lfs -text

.github/workflows/ci.yaml

+55-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ env:
44
# Bump this number to invalidate the Github-actions cache
55
cache-invalidation-key: 0
66
nixpkgs-url: https://github.com/NixOS/nixpkgs/archive/574d1eac1c200690e27b8eb4e24887f8df7ac27c.tar.gz
7+
NIX_PATH: https://github.com/NixOS/nixpkgs/archive/574d1eac1c200690e27b8eb4e24887f8df7ac27c.tar.gz
8+
ghc-exe: $(pwd)/ghc-dps-compact-95615577d7/bin/ghc
9+
ghc-name: ghc-dps-compact-95615577d7
10+
ghc-internal-name: ghc-9.11.20241002-x86_64-unknown-linux
711

812
jobs:
913
cabal-test:
@@ -13,7 +17,9 @@ jobs:
1317
ghc-version: [96, 98, 910]
1418
runs-on: ubuntu-latest
1519
steps:
16-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
21+
with:
22+
lfs: false
1723
- uses: cachix/install-nix-action@v15
1824
with:
1925
nix_path: "${{ env.nixpkgs-url }}"
@@ -35,28 +41,69 @@ jobs:
3541
- name: Build Cabal's dependencies
3642
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build --dependencies-only"
3743
- name: Build
38-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build"
44+
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build --run-tests"
3945
- name: Haddock
4046
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal haddock"
4147
- name: cabal-docspec
4248
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal-docspec"
4349
- name: Build benchmarks
4450
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build linear-base:bench:bench"
45-
- name: Run benchmarks
46-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal bench 2>&1 | tee benchmark_ghc${{ matrix.ghc-version }}.txt"
51+
- name: Run benchmarks in isolation
52+
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "echo $'\n\n=== Benchmarks (isolation) ===\n\n' > benchmark_ghc${{ matrix.ghc-version }}.txt && cabal run -v0 linear-dest:bench:bench -- -l | grep -P 'All\.[^\.]+\.benchmark\.' | while read -r name; do cabal run -v0 linear-dest:bench:bench -- -p '"'$'"0 == \"'\""'$'"name\"'\"' 2>&1 | tee -a benchmark_ghc${{ matrix.ghc-version }}.txt; done"
4753
- name: Upload benchmark results
4854
uses: actions/upload-artifact@v3
4955
with:
5056
name: linear-base_benchmarks_ghc${{ matrix.ghc-version }}
5157
path: |
58+
**/*.dump-simpl
5259
benchmark_ghc${{ matrix.ghc-version }}.txt
5360
retention-days: 90
5461

62+
cabal-test-ghc-dps-compact:
63+
name: cabal test - ${{ env.ghc-name }}
64+
runs-on: [self-hosted, Linux, X64]
65+
steps:
66+
- uses: actions/checkout@v3
67+
with:
68+
lfs: true
69+
- name: Checkout LFS objects
70+
run: git lfs checkout
71+
- name: Build Nix dependencies
72+
run: nix-shell --arg installHls 'false' --pure --run "echo '=== Nix dependencies installed ==='"
73+
- name: Install custom GHC
74+
run: nix-shell --pure --run "rm -rf ${{ env.ghc-name }} ${{ env.ghc-internal-name }} && tar xJf ${{ env.ghc-name }}.tar.xz && mv ${{ env.ghc-internal-name }} ${{ env.ghc-name }}"
75+
- name: Init Cabal's config file
76+
run: nix-shell --arg installHls 'false' --pure --run "cabal --config-file=$HOME/.cabal/config user-config -f init"
77+
- name: Update Cabal's database
78+
run: nix-shell --arg installHls 'false' --pure --run "cabal update"
79+
- name: Build Cabal's dependencies
80+
run: nix-shell --arg installHls 'false' --pure --run "cabal build -w ${{ env.ghc-exe }} --dependencies-only"
81+
- name: Build
82+
run: nix-shell --arg installHls 'false' --pure --run "cabal build -w ${{ env.ghc-exe }} --run-tests"
83+
- name: Haddock
84+
run: nix-shell --arg installHls 'false' --pure --run "cabal haddock -w ${{ env.ghc-exe }}"
85+
- name: cabal-docspec
86+
run: nix-shell --arg installHls 'false' --pure --run "cabal-docspec -w ${{ env.ghc-exe }}"
87+
- name: Build benchmarks
88+
run: nix-shell --arg installHls 'false' --pure --run "cabal build -w ${{ env.ghc-exe }} linear-base:bench:bench"
89+
- name: Run benchmarks in isolation
90+
run: nix-shell --arg installHls 'false' --pure --run "echo $'\n\n=== Benchmarks (isolation) ===\n\n' > benchmark_${{ env.ghc-name }}.txt && cabal run -w ${{ env.ghc-exe }} -v0 linear-dest:bench:bench -- -l | grep -P 'All\.[^\.]+\.benchmark\.' | while read -r name; do cabal run -w ${{ env.ghc-exe }} -v0 linear-dest:bench:bench -- -p '"'$'"0 == \"'\""'$'"name\"'\"' 2>&1 | tee -a benchmark_${{ env.ghc-name }}.txt; done"
91+
- name: Upload benchmark results
92+
uses: actions/upload-artifact@v3
93+
with:
94+
name: linear-base_benchmarks_${{ env.ghc-name }}
95+
path: |
96+
**/*.dump-simpl
97+
benchmark_${{ env.ghc-name }}.txt
98+
retention-days: 90
99+
55100
ormolu:
56101
name: check formatting with ormolu
57102
runs-on: ubuntu-latest
58103
steps:
59-
- uses: actions/checkout@v2
104+
- uses: actions/checkout@v3
105+
with:
106+
lfs: false
60107
- uses: cachix/install-nix-action@v15
61108
with:
62109
nix_path: "${{ env.nixpkgs-url }}"
@@ -75,7 +122,9 @@ jobs:
75122
name: stack build
76123
runs-on: ubuntu-latest
77124
steps:
78-
- uses: actions/checkout@v2
125+
- uses: actions/checkout@v3
126+
with:
127+
lfs: false
79128
- uses: cachix/install-nix-action@v15
80129
with:
81130
nix_path: "${{ env.nixpkgs-url }}"

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ cabal.sandbox.config
2222
.stack-work/
2323
cabal.project.local
2424
.HTF/
25+
26+
**/*.dump-simpl
27+
ghc-dps-compact-95615577d7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Bench.Compact where
2+
3+
import Bench.Compact.BFTraversal (bftraversalBenchgroup)
4+
import Bench.Compact.DList (dlistBenchgroup)
5+
import Bench.Compact.Map (mapBenchgroup)
6+
import Bench.Compact.Queue (queueBenchgroup)
7+
import Bench.Compact.SExpr (sexprBenchgroup)
8+
import Test.Tasty.Bench
9+
10+
benchmarks :: Benchmark
11+
benchmarks =
12+
bgroup
13+
"DPS interface for compact regions"
14+
[ bftraversalBenchgroup,
15+
mapBenchgroup,
16+
dlistBenchgroup,
17+
queueBenchgroup,
18+
sexprBenchgroup
19+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Bench.Compact.BFTraversal where
2+
3+
import Bench.Compact.Utils as Utils
4+
import Compact.BFTraversal as BFTraversal
5+
import Control.DeepSeq (force)
6+
import Control.Exception (evaluate)
7+
import Test.Tasty.Bench (Benchmark)
8+
9+
dataSets :: [(IO (BinTree ()), String)]
10+
dataSets =
11+
[ (evaluate $ force (go 0 10), "2^10"),
12+
(evaluate $ force (go 0 13), "2^13"),
13+
(evaluate $ force (go 0 16), "2^16"),
14+
(evaluate $ force (go 0 19), "2^19"),
15+
(evaluate $ force (go 0 22), "2^22")
16+
]
17+
where
18+
go :: Int -> Int -> BinTree ()
19+
go currentDepth maxDepth =
20+
if currentDepth >= maxDepth
21+
then Nil
22+
else Node () (go (currentDepth + 1) maxDepth) (go (currentDepth + 1) maxDepth)
23+
24+
bftraversalBenchgroup :: Benchmark
25+
bftraversalBenchgroup = Utils.benchImpls "Breadth-first tree traversal" BFTraversal.impls dataSets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{-# OPTIONS_GHC -Wno-type-defaults #-}
2+
3+
module Bench.Compact.DList where
4+
5+
import Bench.Compact.Utils as Utils
6+
import Compact.DList as DList
7+
import Control.DeepSeq (force)
8+
import Control.Exception (evaluate)
9+
import Test.Tasty.Bench (Benchmark)
10+
11+
dataSets :: [(IO [[Int]], String)]
12+
dataSets =
13+
[ (evaluate $ force (fmap (\i -> [(10 * i + 0) .. (10 * i + 9)]) [0 .. (((2 ^ 10) `div` 10) - 1)]), "2^10"),
14+
(evaluate $ force (fmap (\i -> [(10 * i + 0) .. (10 * i + 9)]) [0 .. (((2 ^ 13) `div` 10) - 1)]), "2^13"),
15+
(evaluate $ force (fmap (\i -> [(10 * i + 0) .. (10 * i + 9)]) [0 .. (((2 ^ 16) `div` 10) - 1)]), "2^16"),
16+
(evaluate $ force (fmap (\i -> [(10 * i + 0) .. (10 * i + 9)]) [0 .. (((2 ^ 19) `div` 10) - 1)]), "2^19"),
17+
(evaluate $ force (fmap (\i -> [(10 * i + 0) .. (10 * i + 9)]) [0 .. (((2 ^ 22) `div` 10) - 1)]), "2^22")
18+
]
19+
20+
dlistBenchgroup :: Benchmark
21+
dlistBenchgroup = benchImpls "List and DList concatenation" DList.impls dataSets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{-# LANGUAGE LinearTypes #-}
2+
{-# LANGUAGE TupleSections #-}
3+
{-# OPTIONS_GHC -Wno-type-defaults #-}
4+
5+
module Bench.Compact.Map where
6+
7+
import Bench.Compact.Utils as Utils
8+
import Compact.Map as Map
9+
import Control.DeepSeq (force)
10+
import Control.Exception (evaluate)
11+
import Test.Tasty.Bench (Benchmark)
12+
13+
dataSets :: [(IO [Int], String)]
14+
dataSets =
15+
[ ((evaluate $ force [1 .. 2 ^ 10]), "2^10"),
16+
((evaluate $ force [1 .. 2 ^ 13]), "2^13"),
17+
((evaluate $ force [1 .. 2 ^ 16]), "2^16"),
18+
((evaluate $ force [1 .. 2 ^ 19]), "2^19"),
19+
((evaluate $ force [1 .. 2 ^ 22]), "2^22")
20+
]
21+
22+
mapBenchgroup :: Benchmark
23+
mapBenchgroup = benchImpls "map on List" Map.impls dataSets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{-# OPTIONS_GHC -Wno-type-defaults #-}
2+
3+
module Bench.Compact.Queue where
4+
5+
import Bench.Compact.Utils as Utils
6+
import Compact.Queue as Queue
7+
import Data.Word (Word64)
8+
import Test.Tasty.Bench (Benchmark)
9+
10+
dataSets :: [(IO Word64, String)]
11+
dataSets =
12+
[ (return $ 2 ^ 10, "2^10"),
13+
(return $ 2 ^ 13, "2^13"),
14+
(return $ 2 ^ 16, "2^16"),
15+
(return $ 2 ^ 19, "2^19"),
16+
(return $ 2 ^ 22, "2^22")
17+
]
18+
19+
queueBenchgroup :: Benchmark
20+
queueBenchgroup = benchImpls "Queue enqueue operations" Queue.impls dataSets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module Bench.Compact.SExpr where
2+
3+
import Bench.Compact.Utils as Utils
4+
import Compact.SExpr as SExpr
5+
import Control.DeepSeq (force)
6+
import Control.Exception (evaluate)
7+
import qualified Data.ByteString.Char8 as BSC
8+
import Test.Tasty.Bench (Benchmark)
9+
10+
dataSetDir :: String
11+
dataSetDir = "bench-version-changes/ghc-dps-compact/after/datasets/"
12+
13+
dataSets :: [(IO BSC.ByteString, String)]
14+
dataSets =
15+
[ (evaluate . force =<< BSC.readFile (dataSetDir ++ "data_2_10.sexpr"), "2^10"),
16+
(evaluate . force =<< BSC.readFile (dataSetDir ++ "data_2_13.sexpr"), "2^13"),
17+
(evaluate . force =<< BSC.readFile (dataSetDir ++ "data_2_16.sexpr"), "2^16"),
18+
(evaluate . force =<< BSC.readFile (dataSetDir ++ "data_2_19.sexpr"), "2^19"),
19+
(evaluate . force =<< BSC.readFile (dataSetDir ++ "data_2_22.sexpr"), "2^22")
20+
]
21+
22+
sexprBenchgroup :: Benchmark
23+
sexprBenchgroup = Utils.benchImpls "S-expression parser" SExpr.impls dataSets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{-# LANGUAGE AllowAmbiguousTypes #-}
2+
{-# LANGUAGE DataKinds #-}
3+
{-# LANGUAGE FlexibleContexts #-}
4+
{-# LANGUAGE ImpredicativeTypes #-}
5+
{-# LANGUAGE KindSignatures #-}
6+
{-# LANGUAGE LinearTypes #-}
7+
{-# LANGUAGE ScopedTypeVariables #-}
8+
{-# OPTIONS_GHC -Wno-name-shadowing #-}
9+
10+
module Bench.Compact.Utils where
11+
12+
import Control.DeepSeq
13+
import Control.Exception (evaluate)
14+
import Data.Functor ((<&>))
15+
import GHC.Compact (compact, getCompact)
16+
import Test.Tasty (testGroup)
17+
import Test.Tasty.Bench
18+
19+
-- import qualified Compact.Map as Map
20+
-- import qualified Compact.BFTraversal as BFTraversal
21+
-- import qualified Compact.DList as DList
22+
-- import qualified Compact.Queue as Queue
23+
-- import qualified Compact.SExpr as SExpr
24+
25+
-- import qualified Bench.Compact.Map as Map
26+
-- import qualified Bench.Compact.BFTraversal as BFTraversal
27+
-- import qualified Bench.Compact.DList as DList
28+
-- import qualified Bench.Compact.Queue as Queue
29+
-- import qualified Bench.Compact.SExpr as SExpr
30+
31+
benchImpls :: forall m a r. (NFData a, NFData r) => String -> [(a %m -> r, String, Bool)] -> [(IO a, String)] -> Benchmark
32+
benchImpls name impls datasets = do
33+
bgroup
34+
name
35+
( datasets <&> \(loadSampleData, sizeName) -> env loadSampleData $ \sampleData ->
36+
testGroup sizeName $
37+
concat $
38+
impls <&> \(impl, implName, isLazy) ->
39+
if isLazy
40+
then
41+
[ bench (implName ++ ".force") $ (flip whnfAppIO) sampleData $ \sampleData -> evaluate $ force $ impl sampleData,
42+
bench (implName ++ ".copyIntoReg") $ (flip whnfAppIO) sampleData $ \sampleData -> do
43+
resInRegion <- compact $ impl sampleData
44+
evaluate $ getCompact $ resInRegion
45+
]
46+
else [bench implName $ (flip whnfAppIO) sampleData $ \sampleData -> evaluate $ impl sampleData]
47+
)
48+
49+
-- launchImpl :: String -> IO ()
50+
-- launchImpl s =
51+
-- let (_all, dotModuleName) = span (/= '.') s
52+
-- (moduleName, dotBenchmark) = span (/= '.') (tail dotModuleName)
53+
-- (_benchmark, dotImplSizeSpec) = span (/= '.') (tail dotBenchmark)
54+
-- implSizeSpec = tail dotImplSizeSpec
55+
-- in case (_all ++ "." ++ moduleName ++ "." ++ _benchmark) of
56+
-- "All.Bench.Compact.Map.benchmark" -> Utils.launchImpl' implSizeSpec Map.impls Map.dataSets
57+
-- "All.Bench.Compact.BFTraversal.benchmark" -> Utils.launchImpl' implSizeSpec BFTraversal.impls BFTraversal.dataSets
58+
-- "All.Bench.Compact.DList.benchmark" -> Utils.launchImpl' implSizeSpec DList.impls DList.dataSets
59+
-- "All.Bench.Compact.Queue.benchmark" -> Utils.launchImpl' implSizeSpec Queue.impls Queue.dataSets
60+
-- "All.Bench.Compact.SExpr.benchmark" -> Utils.launchImpl' implSizeSpec SExpr.impls SExpr.dataSets
61+
-- s' -> error ("benchmark group '" ++ s' ++ "' not found")
62+
63+
-- launchImpl' :: forall m a r. (NFData r) => String -> [(a %m -> r, String, Bool)] -> [(IO a, String)] -> IO ()
64+
-- launchImpl' requestedImplDataSetspec impls datasets = go impls (go' datasets) where
65+
-- (requestedSize, dotRequestedImplSpec) = span (/= '.') requestedImplDataSetspec
66+
-- (requestedImplRadical, requestedImplVariant) = span (/= '.') (tail dotRequestedImplSpec)
67+
-- go [] _ = error ("requested implementation '" ++ requestedImplRadical ++ "' not found")
68+
-- go ((impl, implName, isLazy):_) loadSampleData | implName == requestedImplRadical = do
69+
-- sampleData <- loadSampleData
70+
-- if isLazy
71+
-- then case requestedImplVariant of
72+
-- ".force" -> evaluate $ rwhnf $ force $ impl sampleData
73+
-- ".copyIntoReg" -> do
74+
-- resInRegion <- compact $ impl sampleData
75+
-- evaluate $ rwhnf $ getCompact $ resInRegion
76+
-- _ -> error ("variant '" ++ requestedImplVariant ++ "' not found (required for lazy impl)")
77+
-- else
78+
-- evaluate $ rwhnf $ impl sampleData
79+
-- putStrLn "Done!"
80+
-- go (_:xs) loadSampleData = go xs loadSampleData
81+
82+
-- go' [] = error ("requested size '" ++ requestedSize ++ "' not found")
83+
-- go' ((loadSampleData, sizeName):_) | sizeName == requestedSize = loadSampleData
84+
-- go' (_:xs) = go' xs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
(
2+
(ert-deftest company-shows-keywords-alongside-completions-alphabetically ()
3+
:tags '(company)
4+
(switch-to-buffer "*TESTING COMPANY MODE ~ Python*")
5+
(python-mode)
6+
7+
8+
(erase-buffer)
9+
(insert "\n def first(x): pass")
10+
(insert "\n def fierce(a, b): pass")
11+
12+
13+
(insert "\n fi")
14+
(company-manual-begin)
15+
(should (equal company-candidates '("fierce" "first" #("finally" 0 7 (company-backend company-keywords)))))
16+
17+
18+
(execute-kbd-macro (kbd "C-g C-/ M-2"))
19+
(should (looking-back "finally"))
20+
21+
(kill-buffer))
22+
23+
24+
(ert-deftest company-shows-keywords-alongside-completions-alphabetically ()
25+
:tags '(company)
26+
(switch-to-buffer "*TESTING COMPANY MODE ~ Python*")
27+
(python-mode)
28+
29+
30+
(erase-buffer)
31+
(insert "\n def first(x): pass")
32+
(insert "\n def fierce(a, b): pass")
33+
34+
35+
(insert "\n fi")
36+
(company-manual-begin)
37+
(should (equal company-candidates '("fierce" "first" #("finally" 0 7 (company-backend company-keywords)))))
38+
39+
40+
(execute-kbd-macro (kbd "C-g C-/ M-2"))
41+
(should (looking-back "finally"))
42+
43+
(kill-buffer))
44+
45+
46+
)

0 commit comments

Comments
 (0)