diff --git a/server/CONTRIBUTING.md b/server/CONTRIBUTING.md index ad071db2afb..b8bc8f73e4c 100644 --- a/server/CONTRIBUTING.md +++ b/server/CONTRIBUTING.md @@ -292,6 +292,15 @@ This naming convention enables easier test filtering with [pytest command line f The backend-specific and common test suites are disjoint; for example, run `pytest --integration -k "Common or MySQL" --backend mysql` to run all MySQL tests. +#### Building with profiling + +To build with profiling support, you need to both enable profiling via `cabal` +and set the `profiling` flag. E.g. + +``` +cabal build exe:graphql-engine -f profiling --enable-profiling +``` + ### Create Pull Request - Make sure your commit messages meet the [guidelines](../CONTRIBUTING.md). diff --git a/server/graphql-engine.cabal b/server/graphql-engine.cabal index b51f96922a2..aac457c9b08 100644 --- a/server/graphql-engine.cabal +++ b/server/graphql-engine.cabal @@ -118,7 +118,6 @@ library , either , exceptions , fast-logger - , ghc-heap-view , hashable , hashable-time , http-client-tls @@ -290,6 +289,10 @@ library , mysql , mysql-simple + if !flag(profiling) + -- ghc-heap-view can't be built with profiling + build-depends: ghc-heap-view + exposed-modules: Control.Arrow.Extended , Control.Arrow.Trans , Control.Concurrent.Extended diff --git a/server/src-lib/GHC/AssertNF/CPP.hs b/server/src-lib/GHC/AssertNF/CPP.hs index 300c6bb3d95..fa1ab553ec5 100644 --- a/server/src-lib/GHC/AssertNF/CPP.hs +++ b/server/src-lib/GHC/AssertNF/CPP.hs @@ -3,6 +3,29 @@ -- | GHC.AssertNF.CPP localizes our use of CPP around calls -- to 'assertNFHere', primarily to give tooling (e.g. ormolu) -- an easier time. +-- +-- We disable the 'assertNF'-related code because it is provided +-- by the package ghc-heap-view, which can't be built using profiling. + +#ifdef PROFILING + +module GHC.AssertNF.CPP + ( assertNFHere, + disableAssertNF, + ) +where + +import Hasura.Prelude +import Language.Haskell.TH + +assertNFHere :: Q Exp +assertNFHere = [| const (return ()) |] + +disableAssertNF :: IO () +disableAssertNF = return () + +#else + module GHC.AssertNF.CPP ( assertNFHere, disableAssertNF, @@ -13,14 +36,9 @@ where import GHC.AssertNF qualified import Hasura.Prelude import Language.Haskell.TH -#ifndef PROFILING -import Text.Printf (printf) -#endif +import Text.Printf (printf) assertNFHere :: Q Exp -#ifdef PROFILING -assertNFHere = [| const (return ()) |] -#else -- This is a copy of 'GHC.AssertNF.assertNFHere'. We can't easily -- use the original because that relies on an import of "GHC.AssertNF". -- Instead, we rewrite it to use the re-exported 'assertNFNamed'. @@ -32,11 +50,8 @@ assertNFHere = do formatLoc loc = let file = loc_filename loc (line, col) = loc_start loc in printf "parameter at %s:%d:%d" file line col -#endif disableAssertNF :: IO () -#ifdef PROFILING -disableAssertNF = return () -#else disableAssertNF = GHC.AssertNF.disableAssertNF + #endif