on master help sign in
Add a diagnostics flag to debug problems in field
ed0323cHarendra Kumar
.travis.yml+3
@@ -69,6 +69,9 @@ matrix:
69 - env: BUILD=stack CABALVER=2.0 GHCVER=8.2.2 RESOLVER=lts-11 STACK_BUILD_OPTIONS="--flag streamly:examples-sdl"
69 - env: BUILD=stack CABALVER=2.0 GHCVER=8.2.2 RESOLVER=lts-11 STACK_BUILD_OPTIONS="--flag streamly:examples-sdl"
70 addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2,libsdl1.2-dev], sources: [hvr-ghc]}}
70 addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2,libsdl1.2-dev], sources: [hvr-ghc]}}
71
71
72+ - env: BUILD=stack CABALVER=2.0 GHCVER=8.2.2 RESOLVER=lts-11 STACK_BUILD_OPTIONS="--flag streamly:diag"
73+ addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2,libsdl1.2-dev], sources: [hvr-ghc]}}
74+
72 # Nightly
75 # Nightly
73 - env: BUILD=stack RESOLVER=nightly
76 - env: BUILD=stack RESOLVER=nightly
74
77
src/Streamly/Core.hs+4−3
@@ -93,9 +93,10 @@ import GHC.Exts
93import GHC.Conc (ThreadId(..))
93import GHC.Conc (ThreadId(..))
94import GHC.IO (IO(..))
94import GHC.IO (IO(..))
95
95
96−-- MVar diagnostics has some overhead - around 5% on asyncly null benchmark,
96+-- MVar diagnostics has some overhead - around 5% on asyncly null benchmark, we
97−-- but keep it on for now to debug problems quickly if and when they happen.
97+-- can keep it on in production to debug problems quickly if and when they
98−#define DIAGNOSTICS
98+-- happen, but it may result in unexpected output when threads are left hanging
99+-- until they are GCed because the consumer went away.
99
100
100#ifdef DIAGNOSTICS
101#ifdef DIAGNOSTICS
101import Control.Exception (catches, throwIO, Handler(..),
102import Control.Exception (catches, throwIO, Handler(..),
streamly.cabal+12−3
@@ -71,18 +71,23 @@ source-repository head
71 type: git
71 type: git
72 location: https://github.com/composewell/streamly
72 location: https://github.com/composewell/streamly
73
73
74+flag diag
75+ description: Diagnostics build
76+ manual: True
77+ default: False
78+
74flag dev
79flag dev
75− description: Build development version
80+ description: Development build
76 manual: True
81 manual: True
77 default: False
82 default: False
78
83
79flag examples
84flag examples
80− description: Build examples
85+ description: Build including examples
81 manual: True
86 manual: True
82 default: False
87 default: False
83
88
84flag examples-sdl
89flag examples-sdl
85− description: Include examples that use SDL dependency
90+ description: Build including SDL examples
86 manual: True
91 manual: True
87 default: False
92 default: False
88
93
@@ -103,7 +108,11 @@ library
103 default-language: Haskell2010
108 default-language: Haskell2010
104 ghc-options: -Wall
109 ghc-options: -Wall
105
110
111+ if flag(diag)
112+ cpp-options: -DDIAGNOSTICS
113+
106 if flag(dev)
114 if flag(dev)
115+ cpp-options: -DDIAGNOSTICS
107 ghc-options: -Wmissed-specialisations
116 ghc-options: -Wmissed-specialisations
108 -Wall-missed-specialisations
117 -Wall-missed-specialisations
109 -fno-ignore-asserts
118 -fno-ignore-asserts