Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exponential complexity of unions generationΒ #558

@LiLatee

Description

@LiLatee

Hi! Awesome package! Good job! 😊
We are switching quite complex project from artemis to ferry and we were not able to generate code using ferry. It was throwing out of memory error and then we found reuse_fragments option that helped (probably), but then the generation can't finish. It takes infinite time (after 9 hours of processing a single file I gave up).

We've made an investigation and it turned out that the complexity of unions in our queries is the problem.
We have a timeline query that can return 1 of 8 possible objects. We are not able to process that file, but if we remove some of the fragments from the query then we can do it and it doesn't matter which one we remove:

  • 4 fragments takes ~95ms
  • 5 fragments takes ~470ms
  • 6 fragments takes ~6667ms
  • 7 fragments takes ~ for sure more than 1 hour, I was bored to wait more,
  • 8 fragment - I was waiting 9 hours and it didn't finish 😒

I've prepared a repository with an example to reproduce the issue. The example is much simpler than our real project so it can generate even 10 fragments, but it takes about 2 minutes.

The time is checked in the following way:
image
It looks like calling https://github.com/gql-dart/gql/blob/1cabae81a96db119b00d1502043974d1f7b49f70/codegen/gql_code_builder/lib/data.dart#L128 function is responsible for such long times.

Is there any plan to improve that? In our case ferry seems to be not usable 😞

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions