From 4049fbd728c2559823c88889c77b73628ec853a4 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Tue, 27 Jun 2023 17:49:07 +0200 Subject: [PATCH] server: Use `program-options` from Cabal 3.8 to spread `ghc-options` everywhere. This makes it far easier to add new packages without having to add GHC flags everywhere. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9684 GitOrigin-RevId: 1470b618a7e6582ad5053680c89df0c81920402e --- cabal/ci-haddock.project.local | 46 +++-------------- cabal/ci.project.local | 50 ++----------------- cabal/dev-sh.project.local | 49 ++---------------- .../src/Database/Redis/ManualCommands.hs | 6 +-- .../src/Database/Redis/ProtocolPipelining.hs | 2 +- 5 files changed, 19 insertions(+), 134 deletions(-) diff --git a/cabal/ci-haddock.project.local b/cabal/ci-haddock.project.local index 4aaafe0e0df7e..b4d732776e9c0 100644 --- a/cabal/ci-haddock.project.local +++ b/cabal/ci-haddock.project.local @@ -9,48 +9,16 @@ package * ghc-options: -j2 - +RTS -M15000m -RTS + -- For performance, with `-j`: +RTS -A64m -n2m -RTS -- Disable optimizations flags: -optimize-hasura -package graphql-engine - ghc-options: - -- At this point though we definitely want full module-level parallelism: - -j - -Werror - -- For speed; see `cabal.project.dev-sh.local`: - executable-dynamic: True - library-vanilla: False - -package test-harness - ghc-options: -Werror -j - executable-dynamic: True - library-vanilla: False - -package api-tests - ghc-options: -Werror -j - executable-dynamic: True - library-vanilla: False - --- %%%-BEGIN-PRO-ONLY-CONTENT-%%% - -package graphql-engine-pro - ghc-options: - -- At this point though we definitely want full module-level parallelism: - -j - -Werror - -- For speed; see `cabal.project.dev-sh.local`: - executable-dynamic: True - library-vanilla: False - -package test-harness-pro - ghc-options: -Werror -j - executable-dynamic: True - library-vanilla: False +-- Set common options +program-options + ghc-options: -j -Werror -package api-tests-pro - ghc-options: -Werror -j - executable-dynamic: True - library-vanilla: False +-- For speed; see `cabal.project.dev-sh.local`: +executable-dynamic: True +library-vanilla: False diff --git a/cabal/ci.project.local b/cabal/ci.project.local index 18712b7793c51..46a94b8a48694 100644 --- a/cabal/ci.project.local +++ b/cabal/ci.project.local @@ -6,7 +6,6 @@ package * ghc-options: -- We compile with package-level parallelism, so just use a small amount -- of module-level parallelism for dependencies: - -- TODO: tune me -j2 -- For performance, with `-j`: +RTS -A64m -n2m -RTS @@ -14,51 +13,14 @@ package * -- Enable optimizations in all local (hasura) packages: flags: +optimize-hasura +-- Set common options +program-options + ghc-options: -j -Werror + package graphql-engine - ghc-options: - -- At this point though we definitely want full module-level parallelism: - -j - -Werror tests: true benchmarks: true --- Set common options to internal libraries -package aeson-ordered - ghc-options: -j -Werror - -package api-tests - ghc-options: -j -Werror - -package arrows-extra - ghc-options: -j -Werror - -package dc-api - ghc-options: -j -Werror - -package graphql-parser - ghc-options: -j -Werror - -package hasura-error-message - ghc-options: -j -Werror - -package hasura-incremental - ghc-options: -j -Werror - -package hasura-prelude - ghc-options: -j -Werror - -package hasura-schema-parsers - ghc-options: -j -Werror - -package pg-client - ghc-options: -j -Werror - -package resource-pool - ghc-options: -j -Werror - -package test-harness - ghc-options: -j -Werror - -- %%%-BEGIN-PRO-ONLY-CONTENT-%%% -- NOTE: @@ -69,8 +31,4 @@ package test-harness -- `copy.bara.sky`), so please take care when manipulating this label! package graphql-engine-pro - ghc-options: - -- At this point though we definitely want full module-level parallelism: - -j - -Werror tests: true diff --git a/cabal/dev-sh.project.local b/cabal/dev-sh.project.local index 70f8832b852a8..c95ba4dcabdd3 100644 --- a/cabal/dev-sh.project.local +++ b/cabal/dev-sh.project.local @@ -23,6 +23,10 @@ package * -- optimizations disabled. See https://gitlab.haskell.org/ghc/ghc/-/issues/16932 ghc-options: -fsolve-constant-dicts +-- Set common options for local libraries +program-options + ghc-options: -j -Werror + -- NOTE: new-build may report a misleading 'Build profile: -O1' -- See:https://github.com/haskell/cabal/issues/6221 flags: -optimize-hasura @@ -32,20 +36,12 @@ package graphql-engine -- which is not what we originally wanted. But building the test modules -- themselves with coverage is actually nice for validation. coverage: true - -- to match CI: - ghc-options: -Werror - -- For compile-time performance (see cabal.project.ci.local): - ghc-options: -j package graphql-engine-pro -- NOTE: 'cabal new-build --enable-coverage' seems to rebuild all deps with coverage -- which is not what we originally wanted. But building the test modules -- themselves with coverage is actually nice for validation. coverage: true - -- to match CI: - ghc-options: -Werror - -- For compile-time performance (see cabal.project.ci.local): - ghc-options: -j -- By default GHC is dynamically linked, so to run TemplateHaskell you need dynamic versions of -- libraries. But, also by default, cabal links executables statically, which requires static @@ -67,43 +63,6 @@ package Spock package hasql-pool library-vanilla: False --- Set common options to internal libraries -package aeson-ordered - ghc-options: -j -Werror - -package api-tests - ghc-options: -j -Werror - -package arrows-extra - ghc-options: -j -Werror - -package dc-api - ghc-options: -j -Werror - -package graphql-parser - ghc-options: -j -Werror - -package error-message - ghc-options: -j -Werror - -package incremental - ghc-options: -j -Werror - -package hasura-prelude - ghc-options: -j -Werror - -package schema-parsers - ghc-options: -j -Werror - -package pg-client - ghc-options: -j -Werror - -package resource-pool - ghc-options: -j -Werror - -package test-harness - ghc-options: -j -Werror - package mysql extra-include-dirs: /opt/homebrew/opt/openssl/include diff --git a/server/forks/hedis/src/Database/Redis/ManualCommands.hs b/server/forks/hedis/src/Database/Redis/ManualCommands.hs index 9c0933214e38c..e6d08c7e01462 100644 --- a/server/forks/hedis/src/Database/Redis/ManualCommands.hs +++ b/server/forks/hedis/src/Database/Redis/ManualCommands.hs @@ -847,8 +847,8 @@ instance RedisResult StreamsRecord where return StreamsRecord{..} where decodeKeyValues :: [ByteString] -> [(ByteString, ByteString)] - decodeKeyValues bs = map (\[x,y] -> (x,y)) $ chunksOfTwo bs - chunksOfTwo (x:y:rest) = [x,y]:chunksOfTwo rest + decodeKeyValues bs = chunksOfTwo bs + chunksOfTwo (x:y:rest) = (x, y) : chunksOfTwo rest chunksOfTwo _ = [] decode a = Left a @@ -1430,4 +1430,4 @@ command :: (RedisCtx m f) => m (f [CMD.CommandInfo]) command = sendRequest ["COMMAND"] readOnly :: (RedisCtx m f) => m (f Status) -readOnly = sendRequest ["READONLY"] \ No newline at end of file +readOnly = sendRequest ["READONLY"] diff --git a/server/forks/hedis/src/Database/Redis/ProtocolPipelining.hs b/server/forks/hedis/src/Database/Redis/ProtocolPipelining.hs index 8ba3cc8758b0c..0e0f6c22feff2 100644 --- a/server/forks/hedis/src/Database/Redis/ProtocolPipelining.hs +++ b/server/forks/hedis/src/Database/Redis/ProtocolPipelining.hs @@ -132,7 +132,7 @@ connGetReplies conn@Conn{..} = go S.empty (SingleLine "previous of first") Scanner.Done rest' r -> do -- r is the same as 'head' of 'connPending'. Since we just -- received r, we remove it from the pending list. - atomicModifyIORef' connPending $ \(_:rs) -> (rs, ()) + atomicModifyIORef' connPending $ (\rs -> (rs, ())) . tail -- We now expect one less reply from Redis. We don't count to -- negative, which would otherwise occur during pubsub. atomicModifyIORef' connPendingCnt $ \n -> (max 0 (n-1), ())