Skip to content

Commit

Permalink
server: Use program-options from Cabal 3.8 to spread ghc-options
Browse files Browse the repository at this point in the history
…everywhere.

This makes it far easier to add new packages without having to add GHC flags everywhere.

PR-URL: hasura/graphql-engine-mono#9684
GitOrigin-RevId: 1470b618a7e6582ad5053680c89df0c81920402e
  • Loading branch information
SamirTalwar authored and hasura-bot committed Jun 27, 2023
1 parent 87abdf1 commit 4049fbd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 134 deletions.
46 changes: 7 additions & 39 deletions cabal/ci-haddock.project.local
Original file line number Diff line number Diff line change
Expand Up @@ -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
50 changes: 4 additions & 46 deletions cabal/ci.project.local
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,21 @@ 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

-- 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:
Expand All @@ -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
49 changes: 4 additions & 45 deletions cabal/dev-sh.project.local
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions server/forks/hedis/src/Database/Redis/ManualCommands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]
readOnly = sendRequest ["READONLY"]
Original file line number Diff line number Diff line change
Expand Up @@ -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), ())
Expand Down

0 comments on commit 4049fbd

Please sign in to comment.