Tyler Wong
11/28/2023, 9:06 AMGQLDocument.validateAsExecutable and again when building IR, our build is severely impacted by heavy fragment re-use which results in very long validation times. These validation calls also recursively call validate on every selection set, so it seems some entities are being validated multiple times.
More in 🧵Tyler Wong
11/28/2023, 9:06 AMCodegenTest to run over our source files. Are there changes in v4.0.0 that could have improved anything? Java codegen finishes and builds in about 8 minutes on v2.3.1 (super old I know 😅), but on v3.8.2, fragment validation on the first pass takes about 41 minutes and operation validation on the first pass takes about 29 minutes. Some of the fragments and operations are validated once more when building IR, so validation takes close to 2 hours. After getting through document validation and building IR, we ended up with an OOM error while writing file infos after a grand total of 1 hour and 58 minutes.Tyler Wong
11/28/2023, 9:07 AMvalidate is necessary to maintain the integrity of the document. Could we optimize our fragment/operation definitions to help too? I’m currently working on getting an obfuscated version of our source. I also saw this issue and was surprised to not find anything about the validation steps taking a long time.
For context, we have over 5k type definitions in our schema, including over 1k fragments defined and over 200 operations. CodegenTest was altered to generate Kotlin models and use operation-based codegen when testing our build.
Sorry for the super long read, but hoping we can get somewhere!mbonnin
11/28/2023, 9:22 AMmbonnin
11/28/2023, 9:24 AMfieldsCanMerge , we have an issue to speed things up there but haven't got to it yet. It's hard to "memo" stuff because every fragment needs to be validated in the context of its operationmbonnin
11/28/2023, 9:27 AMmbonnin
11/29/2023, 11:05 PMTyler Wong
11/29/2023, 11:14 PMCodegenTest. Will upload here shortly!Tyler Wong
11/29/2023, 11:21 PMscalarMapping = mapOf(
"ykvogxdjcr" to ScalarInfo("java.lang.String"),
"dgsalnbfnk" to ScalarInfo("java.lang.String"),
"owblnrurns" to ScalarInfo("java.lang.String"),
"fxvpqiduxs" to ScalarInfo("java.lang.String"),
"ebjtupyrji" to ScalarInfo("java.lang.String"),
"vtxouwljjr" to ScalarInfo("java.lang.String"),
"inpciuewhq" to ScalarInfo("java.lang.String"),
"fkukbftrbi" to ScalarInfo("java.lang.String"),
"buoguxadgo" to ScalarInfo("java.lang.String"),
"dujbacbaoz" to ScalarInfo("java.lang.String"),
),
I’m still stepping through the code to see what the actual bottleneck is for this example, although it seems to be selectionSet.validate and not fieldsInSetCanMerge. Not 100% sure yet though.mbonnin
11/29/2023, 11:44 PMfieldsInSetCanMerge sounds like a good candidate!mbonnin
11/29/2023, 11:54 PMmbonnin
11/30/2023, 12:00 AMresponseBased codegen by any chance?mbonnin
11/30/2023, 12:07 AMTyler Wong
11/30/2023, 12:19 AMdetectCycles addition in 4.x is short-circuiting our validation chain?
Sounds good! Thanks for taking a look. Will do 👍Tyler Wong
11/30/2023, 12:25 AMoperationBased. responseBased didn’t finish (or I gave up) when I tried it on the obfuscated example.mbonnin
11/30/2023, 12:30 AMmbonnin
11/30/2023, 12:34 AMTyler Wong
11/30/2023, 1:21 AMmbonnin
11/30/2023, 8:58 AMpossibleTypes but looks more like v3 was traversing more than needed.Tyler Wong
11/30/2023, 7:10 PMmbonnin
11/30/2023, 7:11 PMmbonnin
11/30/2023, 7:11 PMTyler Wong
11/30/2023, 7:12 PM