Projects STRLCPY graphql-engine Commits a9216a41
🤬
  • server: define instance Functor InputFieldsParser by hand to lower memory usage slightly

    fwiw: I was looking here because ghc-debug showed many closures associated with the Applicative instance,
    but defining Monoid/Semigroup by hand and inlining didn't seem to have any effect
    
    PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7026
    GitOrigin-RevId: 22bb57950bd4f837ce7e33ac9d15fa48a4cb3558
  • Loading...
  • Brandon Simmons committed with hasura-bot 2 months ago
    a9216a41
    1 parent 6329092b
  • ■ ■ ■ ■ ■
    server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Internal/Input.hs
    skipped 63 lines
    64 64   { ifDefinitions :: [Definition origin (InputFieldInfo origin)],
    65 65   ifParser :: HashMap Name (InputValue Variable) -> m a
    66 66   }
    67  - deriving (Functor)
     67 + 
     68 +-- Note: this is just derived Functor instance, but by hand so we can inline
     69 +-- which reduces huge_schema schema memory by 3% at time of writing
     70 +instance (Functor m) => Functor (InputFieldsParser origin m) where
     71 + {-# INLINE fmap #-}
     72 + fmap f = \(InputFieldsParser d p) -> InputFieldsParser d (fmap (fmap f) p)
    68 73   
    69 74  instance Applicative m => Applicative (InputFieldsParser origin m) where
     75 + {-# INLINE pure #-}
    70 76   pure v = InputFieldsParser [] (const $ pure v)
     77 + {-# INLINE (<*>) #-}
    71 78   a <*> b =
    72 79   InputFieldsParser
    73 80   (ifDefinitions a <> ifDefinitions b)
    skipped 345 lines
Please wait...
Page is in error, reload to recover