graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.GC

Synopsis

Documentation

ourIdleGC Source #

Arguments

:: Logger Hasura 
-> DiffTime

Run a major GC when we've been "idle" for idleInterval

-> DiffTime

...as long as it has been > minGCInterval time since the last major GC

-> DiffTime

Additionally, if it has been > maxNoGCInterval time, force a GC regardless.

-> IO void 

The RTS's idle GC doesn't work for us:

  • when `-I` is too low it may fire continuously causing scary high CPU when idle among other issues (see #2565)
  • when we set it higher it won't run at all leading to memory being retained when idle (especially noticeable when users are benchmarking and see memory stay high after finishing). In the theoretical worst case there is such low haskell heap pressure that we never run finalizers to free the foreign data from e.g. libpq.
  • as of GHC 8.10.2 we have access to `-Iw`, but those two knobs still don’t give us a guarantee that a major GC will always run at some minumum frequency (e.g. for finalizers)

...so we hack together our own using GHC.Stats, which should have insignificant runtime overhead.