Skip to content

Commit

Permalink
Lower stack chunk size in RTS to reduce thread STACK memory (closes h…
Browse files Browse the repository at this point in the history
…asura#5190)

This reduces memory consumption for new idle subscriptions significantly
(see linked ticket).

The hypothesis is: we fork a lot of threads per websocket, and some of
these use slightly more than the initial 1K stack size, so the first
overflow balloons to 32K, when significantly less is required.

However: running with `+RTS -K1K -xc` did not seem to show evidence of
any overflows! So it's a mystery why this improves things.

GHC should probably also be doubling the stack buffer at each overflow
or doing something even smarter; the knobs we have aren't so helpful.
  • Loading branch information
jberryman authored and stevefan1999-personal committed Sep 12, 2020
1 parent 8cf5a9c commit 282166f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/graphql-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ common common-exe
-- limiting the parallel GC to 2 or 3 capabilities as a very conservative choice, since more
-- than that is highly unlikely to ever be helpful. More benchmarking would be useful to know if
-- this is the right decision. It’s possible it would better to just turn it off completely.
"-with-rtsopts=-N -I2 -qn2"
--
-- `-kc8K` helps limit memory consumption in websockets (perhaps elsewhere) by making the
-- cost of a thread's first (and probably only) stack overflow less severe.
-- See:https://github.com/hasura/graphql-engine/issues/5190
"-with-rtsopts=-N -I2 -qn2 -kc8K"

library
import: common-all
Expand Down

0 comments on commit 282166f

Please sign in to comment.