[
https://issues.apache.org/jira/browse/SLING-10118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17330880#comment-17330880
]
Thierry Ygé commented on SLING-10118:
-------------------------------------
[~bdelacretaz] in our tests, caching the schema help to reduce by 25% an
initial 17 min test duration.
In fact at the request level for the generated schema, it saved an extra 200 ms
per request, which is the time it need to perform the "buildSchema" code in
that specific context independently of the query complexity. As we need to
quickly re-fetch a lot of content that execute GraphQL queries (for example
about 33k requests , with 20 parallel worker threads, we saved up to 5 min of
computations).
So for requests that would generally need 400 ms to respond, it will save
around 50% , for request that take 20s it save still about 200 ms (as it is the
same schema just a more complex query), but since there are more likely
requests that served response in 400 ms, the average saved time was about 25%
at the end.
So the more your Schema (SDL) is large the more time is saved with that extra
caching, and the gain is likely to appear on low complexity GraphQL queries.
Caching or not caching based on some annotation could be an idea, currently we
don't see in our use cases why it wouldn't need to be cached, but you may have
some other use cases in mind.
> Fully cache the GraphQLSchema objects
> -------------------------------------
>
> Key: SLING-10118
> URL: https://issues.apache.org/jira/browse/SLING-10118
> Project: Sling
> Issue Type: Bug
> Components: GraphQL
> Affects Versions: GraphQL Core 0.0.10
> Reporter: Thierry Ygé
> Priority: Major
>
> Currently in SLING-10085 the GraphQLSchema couldn't be cached due to wired
> resource.
> Thus it still need half the time to spend on building the schema, while
> generally the resource is only used to be passed later to the fetcher. As
> that resource then change, I suggested to wrap it via a proxy Resource
> implementation that would be passed instead of the real resource.
> That proxy will then use a map to lookup for the current resource used at
> execute/validate time. The key for the map is to use the current thread.
> I will submit a PR with the solution I suggest to use.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)