https://kotlinlang.org logo
Title
j

jmfayard

06/20/2022, 2:20 PM
Hello friends In my
schema.graphql
, I have 13 queries and 6 mutations. graphql-kotlin takes about 3s to generate the
GraphQL
object. I don't mind on server startup, but it makes the unit tests slow. Is there something I can do to investigate & improve performance?
d

Dariusz Kuc

06/20/2022, 3:47 PM
👋 3s does seem excessive but unfortunately I don't think we ever done benchmarking on how long it takes to create the schema so hard to say whether it is expected or not
j

jmfayard

06/20/2022, 3:48 PM
Thanks for your answer. If there is a way to improve performance, would that be mostly in graphql-java or in graphql-kotlin?
d

Dariusz Kuc

06/20/2022, 3:49 PM
reflection is pretty slow but still 3s seems pretty excessive if you ask me
how many types your schema defines?
also are you limiting the amount of packages ("supported packages" param) to scan by classgraph?
j

jmfayard

06/20/2022, 3:55 PM
yes I have a number of features and everywhere I use
supportedPackages = listOf("com.tignum.backend.features.$FEATURE$.graphql"),
I have about 60 types, including them all: outputs, inputs, enums, union interfaces
d

Dariusz Kuc

06/20/2022, 3:56 PM
thats not many
have you tried running a profiler to see where the time is spent?
j

jmfayard

06/20/2022, 4:02 PM
yes but I have not the least idea on how to interpret it
d

Dariusz Kuc

06/20/2022, 4:02 PM
looks like our spring example app with handful of queries takes ~2s to start on my machine (also includes some overhead from spring)
j

jmfayard

06/20/2022, 4:03 PM
d

Dariusz Kuc

06/20/2022, 4:12 PM
It looks like most of the time is spent going through the classpath
j

jmfayard

06/20/2022, 5:33 PM
Could it be that it scans for packages
com.tignum.backend.features.$FEATURE$.graphql
in all my Gradle dependencies, while it's in fact only present in my own source code?
d

Dariusz Kuc

06/20/2022, 5:34 PM
might be
it is supposed to be very fast -> https://github.com/classgraph/classgraph
j

jmfayard

06/20/2022, 5:55 PM
That does make a difference! From 700ms to 220m if I only scan my own code. I have 198 dependencies by the way...