Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
-
b3bc7f3b
by Cheng Shao at 2026-04-23T16:54:47-04:00
-
52c9abbb
by Cheng Shao at 2026-04-23T16:54:47-04:00
-
55fd9e40
by Cheng Shao at 2026-04-23T16:54:47-04:00
-
05688630
by Cheng Shao at 2026-04-23T16:54:48-04:00
5 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- + changelog.d/binary-array-no-list
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Utils/Binary.hs
Changes:
| ... | ... | @@ -445,7 +445,7 @@ opsysVariables _ FreeBSD14 = mconcat |
| 445 | 445 | -- Prefer to use the system's clang-based toolchain and not gcc
|
| 446 | 446 | , "CC" =: "cc"
|
| 447 | 447 | , "CXX" =: "c++"
|
| 448 | - , "FETCH_GHC_VERSION" =: "9.10.1"
|
|
| 448 | + , "FETCH_GHC_VERSION" =: "9.10.3"
|
|
| 449 | 449 | , "CABAL_INSTALL_VERSION" =: "3.14.2.0"
|
| 450 | 450 | ]
|
| 451 | 451 | opsysVariables arch (Linux distro) = distroVariables arch distro
|
| ... | ... | @@ -1721,7 +1721,7 @@ |
| 1721 | 1721 | "CC": "cc",
|
| 1722 | 1722 | "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
|
| 1723 | 1723 | "CXX": "c++",
|
| 1724 | - "FETCH_GHC_VERSION": "9.10.1",
|
|
| 1724 | + "FETCH_GHC_VERSION": "9.10.3",
|
|
| 1725 | 1725 | "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
| 1726 | 1726 | "RUNTEST_ARGS": "",
|
| 1727 | 1727 | "TEST_ENV": "x86_64-freebsd14-validate",
|
| ... | ... | @@ -4543,7 +4543,7 @@ |
| 4543 | 4543 | "CC": "cc",
|
| 4544 | 4544 | "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
|
| 4545 | 4545 | "CXX": "c++",
|
| 4546 | - "FETCH_GHC_VERSION": "9.10.1",
|
|
| 4546 | + "FETCH_GHC_VERSION": "9.10.3",
|
|
| 4547 | 4547 | "IGNORE_PERF_FAILURES": "all",
|
| 4548 | 4548 | "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
| 4549 | 4549 | "RUNTEST_ARGS": "",
|
| ... | ... | @@ -5643,7 +5643,7 @@ |
| 5643 | 5643 | "CC": "cc",
|
| 5644 | 5644 | "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
|
| 5645 | 5645 | "CXX": "c++",
|
| 5646 | - "FETCH_GHC_VERSION": "9.10.1",
|
|
| 5646 | + "FETCH_GHC_VERSION": "9.10.3",
|
|
| 5647 | 5647 | "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
| 5648 | 5648 | "RUNTEST_ARGS": "",
|
| 5649 | 5649 | "TEST_ENV": "x86_64-freebsd14-validate"
|
| 1 | +section: compiler
|
|
| 2 | +synopsis: Reduce allocations when (de)serialising `Array` in the `ghc` library.
|
|
| 3 | +issues: #27109
|
|
| 4 | +mrs: !15805
|
|
| 5 | + |
|
| 6 | +description: {
|
|
| 7 | + The `ghc` library's `Binary` instance for `Array` was changed to
|
|
| 8 | + avoid allocating an intermediate list and to omit a redundant length
|
|
| 9 | + field during (de)serialisation.
|
|
| 10 | + |
|
| 11 | + This should only affect the `ghc` library's (de)serialisation code paths,
|
|
| 12 | + primarily when parsing HIE files and bytecode objects.
|
|
| 13 | +} |
| ... | ... | @@ -139,6 +139,7 @@ import Foreign.C |
| 139 | 139 | import System.IO
|
| 140 | 140 | import Data.Data
|
| 141 | 141 | import Data.IORef
|
| 142 | +import qualified Data.List.NonEmpty as NE
|
|
| 142 | 143 | import Data.Semigroup as Semi
|
| 143 | 144 | |
| 144 | 145 | import Foreign
|
| ... | ... | @@ -232,6 +233,7 @@ instance IsString FastString where |
| 232 | 233 | |
| 233 | 234 | instance Semi.Semigroup FastString where
|
| 234 | 235 | (<>) = appendFS
|
| 236 | + sconcat = concatFS . NE.toList
|
|
| 235 | 237 | |
| 236 | 238 | instance Monoid FastString where
|
| 237 | 239 | mempty = nilFS
|
| ... | ... | @@ -619,6 +621,42 @@ unpackFS fs = utf8DecodeShortByteString $ fs_sbs fs |
| 619 | 621 | zEncodeFS :: FastString -> FastZString
|
| 620 | 622 | zEncodeFS fs = fs_zenc fs
|
| 621 | 623 | |
| 624 | +-- Sometimes an `appendFS` operand is temporarily constructed, and we
|
|
| 625 | +-- should avoid retaining the unused `FastString` operand in the
|
|
| 626 | +-- table. The RULES below mitigate the issue by concatenating the
|
|
| 627 | +-- `ShortByteString`s instead when an operand is `fsLit` or
|
|
| 628 | +-- `mkFastString`, which cover most such `appendFS` use cases. See
|
|
| 629 | +-- #27205.
|
|
| 630 | + |
|
| 631 | +{-# RULES
|
|
| 632 | +"appendFS/fsLit y" forall x y.
|
|
| 633 | + appendFS x (fsLit y) =
|
|
| 634 | + mkFastStringShortByteString $
|
|
| 635 | + fs_sbs x Semi.<> utf8EncodeShortByteString y
|
|
| 636 | + #-}
|
|
| 637 | + |
|
| 638 | +{-# RULES
|
|
| 639 | +"appendFS/fsLit x" forall x y.
|
|
| 640 | + appendFS (fsLit x) y =
|
|
| 641 | + mkFastStringShortByteString $
|
|
| 642 | + utf8EncodeShortByteString x Semi.<> fs_sbs y
|
|
| 643 | + #-}
|
|
| 644 | + |
|
| 645 | +{-# RULES
|
|
| 646 | +"appendFS/mkFastString y" forall x y.
|
|
| 647 | + appendFS x (mkFastString y) =
|
|
| 648 | + mkFastStringShortByteString $
|
|
| 649 | + fs_sbs x Semi.<> utf8EncodeShortByteString y
|
|
| 650 | + #-}
|
|
| 651 | + |
|
| 652 | +{-# RULES
|
|
| 653 | +"appendFS/mkFastString x" forall x y.
|
|
| 654 | + appendFS (mkFastString x) y =
|
|
| 655 | + mkFastStringShortByteString $
|
|
| 656 | + utf8EncodeShortByteString x Semi.<> fs_sbs y
|
|
| 657 | + #-}
|
|
| 658 | + |
|
| 659 | +{-# INLINE[1] appendFS #-}
|
|
| 622 | 660 | appendFS :: FastString -> FastString -> FastString
|
| 623 | 661 | appendFS fs1 fs2 = mkFastStringShortByteString
|
| 624 | 662 | $ (Semi.<>) (fs_sbs fs1) (fs_sbs fs2)
|
| ... | ... | @@ -142,6 +142,8 @@ import Control.DeepSeq |
| 142 | 142 | import Control.Monad ( when, (<$!>), unless, forM_, void )
|
| 143 | 143 | import Foreign hiding (bit, setBit, clearBit, shiftL, shiftR, void)
|
| 144 | 144 | import Data.Array
|
| 145 | +import Data.Array.Base (unsafeFreezeIOArray)
|
|
| 146 | +import Data.Array.IArray (traverseArray_)
|
|
| 145 | 147 | import Data.Array.IO
|
| 146 | 148 | import Data.Array.Unsafe
|
| 147 | 149 | import qualified Data.Binary as Binary
|
| ... | ... | @@ -970,11 +972,12 @@ instance Binary a => Binary (NonEmpty a) where |
| 970 | 972 | instance (Ix a, Binary a, Binary b) => Binary (Array a b) where
|
| 971 | 973 | put_ bh arr = do
|
| 972 | 974 | put_ bh $ bounds arr
|
| 973 | - put_ bh $ elems arr
|
|
| 975 | + traverseArray_ (put_ bh) arr
|
|
| 976 | + |
|
| 974 | 977 | get bh = do
|
| 975 | - bounds <- get bh
|
|
| 976 | - xs <- get bh
|
|
| 977 | - return $ listArray bounds xs
|
|
| 978 | + (l, u) <- get bh
|
|
| 979 | + marr <- newGenArray (l, u) $ \_ -> get bh
|
|
| 980 | + unsafeFreezeIOArray marr
|
|
| 978 | 981 | |
| 979 | 982 | instance Binary a => Binary (SmallArray a) where
|
| 980 | 983 | put_ bh sa = do
|