Projects STRLCPY graphql-engine Commits b6e196b9
🤬
  • server: add INLINE to some schema-parsers functions

    This improves memory residency, at least before queries arrive.
    Compile time and binary size seem about the same.
    
    In starting to look at a dominator tree of the heap loading chinook, I
    saw a chain of alternating function/InputFieldsParser closures from
    updateOperator, and I was curious what would happen if I inlined some of
    the continuation-passing -like schema parser functions. It looks like it
    forces some function closure thunks, but I don't have more insight than
    that.
    
    GitOrigin-RevId: 0ebfadfa258e3d15e9e556afe7b54a3c585d2ef4
  • Loading...
  • Brandon Simmons committed with hasura-bot 2 months ago
    b6e196b9
    1 parent 354145f2
  • ■ ■ ■ ■ ■ ■
    server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Directives.hs
    skipped 109 lines
    110 110   G.DirectiveLocation ->
    111 111   [G.Directive Variable] ->
    112 112   m DirectiveMap
     113 +{-# INLINE parseDirectives #-}
    113 114  parseDirectives directiveParsers location givenDirectives = do
    114 115   result <-
    115 116   catMaybes <$> for givenDirectives \directive -> do
    skipped 160 lines
    276 277   [G.DirectiveLocation] ->
    277 278   InputFieldsParser origin m a ->
    278 279   Directive origin m
     280 +{-# INLINE mkDirective #-}
    279 281  mkDirective name description advertised location argsParser =
    280 282   Directive
    281 283   { dDefinition = DirectiveInfo name description (ifDefinitions argsParser) location,
    skipped 10 lines
  • ■ ■ ■ ■ ■
    server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Internal/Input.hs
    skipped 238 lines
    239 239   Maybe Description ->
    240 240   Parser origin k m a ->
    241 241   InputFieldsParser origin m a
     242 +{-# INLINE field #-}
    242 243  field name description parser =
    243 244   InputFieldsParser
    244 245   { ifDefinitions = [Definition name description Nothing [] $ InputFieldInfo (pType parser) Nothing],
    skipped 22 lines
    267 268   Maybe Description ->
    268 269   Parser origin k m a ->
    269 270   InputFieldsParser origin m (Maybe a)
     271 +{-# INLINE fieldOptional #-}
    270 272  fieldOptional name description parser =
    271 273   InputFieldsParser
    272 274   { ifDefinitions =
    skipped 19 lines
    292 294   Value Void ->
    293 295   Parser origin k m a ->
    294 296   InputFieldsParser origin m a
     297 +{-# INLINE fieldWithDefault #-}
    295 298  fieldWithDefault name description defaultValue parser =
    296 299   InputFieldsParser
    297 300   { ifDefinitions = [Definition name description Nothing [] $ InputFieldInfo (pType parser) (Just defaultValue)],
    skipped 53 lines
    351 354   Maybe Description ->
    352 355   InputFieldsParser origin m a ->
    353 356   Parser origin 'Input m a
     357 +{-# INLINE object #-}
    354 358  object name description parser =
    355 359   Parser
    356 360   { pType = schemaType,
    skipped 25 lines
    382 386   invalidName key = parseError $ "variable value contains object with key " <> ErrorValue.dquote key <> ", which is not a legal GraphQL name"
    383 387   
    384 388  list :: forall origin k m a. (MonadParse m, 'Input <: k) => Parser origin k m a -> Parser origin k m [a]
     389 +{-# INLINE list #-}
    385 390  list parser =
    386 391   gcastWith
    387 392   (inputParserInput @k)
    skipped 26 lines
  • ■ ■ ■ ■ ■ ■
    server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Internal/Parser.hs
    skipped 184 lines
    185 185   Maybe Description ->
    186 186   [FieldParser origin m a] ->
    187 187   n (Parser origin 'Output m (OMap.InsOrdHashMap Name (ParsedSelection a)))
     188 +{-# INLINE safeSelectionSet #-}
    188 189  safeSelectionSet name description fields
    189 190   | null duplicates = pure $ selectionSetObject name description fields []
    190 191   | otherwise =
    skipped 32 lines
    223 224   -- see Note [The interfaces story] in Hasura.GraphQL.Parser.Schema.
    224 225   [Parser origin 'Output m b] ->
    225 226   Parser origin 'Output m (OMap.InsOrdHashMap Name (ParsedSelection a))
     227 +{-# INLINE selectionSetObject #-}
    226 228  selectionSetObject name description parsers implementsInterfaces =
    227 229   Parser
    228 230   { pType =
    skipped 50 lines
    279 281   -- Note [The interfaces story] in Hasura.GraphQL.Parser.Schema for details.
    280 282   t (Parser origin 'Output n b) ->
    281 283   Parser origin 'Output n (t b)
     284 +{-# INLINE selectionSetInterface #-}
    282 285  selectionSetInterface name description fields objectImplementations =
    283 286   Parser
    284 287   { pType =
    skipped 21 lines
    306 309   -- | The member object types.
    307 310   t (Parser origin 'Output n b) ->
    308 311   Parser origin 'Output n (t b)
     312 +{-# INLINE selectionSetUnion #-}
    309 313  selectionSetUnion name description objectImplementations =
    310 314   Parser
    311 315   { pType =
    skipped 20 lines
    332 336   -- | type of the result
    333 337   Parser origin 'Both m b ->
    334 338   FieldParser origin m a
     339 +{-# INLINE selection #-}
    335 340  selection name description argumentsParser resultParser =
    336 341   rawSelection name description argumentsParser resultParser
    337 342   <&> \(_alias, _args, a) -> a
    skipped 9 lines
    347 352   Parser origin 'Both m b ->
    348 353   -- | alias provided (if any), and the arguments
    349 354   FieldParser origin m (Maybe Name, HashMap Name (Value Variable), a)
     355 +{-# INLINE rawSelection #-}
    350 356  rawSelection name description argumentsParser resultParser =
    351 357   FieldParser
    352 358   { fDefinition =
    skipped 36 lines
    389 395   -- | parser for the subselection set
    390 396   Parser origin 'Output m b ->
    391 397   FieldParser origin m (a, b)
     398 +{-# INLINE subselection #-}
    392 399  subselection name description argumentsParser bodyParser =
    393 400   rawSubselection name description argumentsParser bodyParser
    394 401   <&> \(_alias, _args, a, b) -> (a, b)
    skipped 8 lines
    403 410   -- | parser for the subselection set
    404 411   Parser origin 'Output m b ->
    405 412   FieldParser origin m (Maybe Name, HashMap Name (Value Variable), a, b)
     413 +{-# INLINE rawSubselection #-}
    406 414  rawSubselection name description argumentsParser bodyParser =
    407 415   FieldParser
    408 416   { fDefinition =
    skipped 19 lines
    428 436   -- | type of the result
    429 437   Parser origin 'Both m a ->
    430 438   FieldParser origin m ()
     439 +{-# INLINE selection_ #-}
    431 440  selection_ name description = selection name description (pure ())
    432 441   
    433 442  -- | A shorthand for a 'subselection' that takes no arguments.
    skipped 4 lines
    438 447   -- | parser for the subselection set
    439 448   Parser origin 'Output m a ->
    440 449   FieldParser origin m a
     450 +{-# INLINE subselection_ #-}
    441 451  subselection_ name description bodyParser =
    442 452   snd <$> subselection name description (pure ()) bodyParser
    443 453   
Please wait...
Page is in error, reload to recover