Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel get extended field definitions #541

Open
3 tasks done
coolbeevip opened this issue Jun 5, 2021 · 0 comments
Open
3 tasks done

Parallel get extended field definitions #541

coolbeevip opened this issue Jun 5, 2021 · 0 comments

Comments

@coolbeevip
Copy link

I want to suggest an idea and checked that ...

  • ... to my best knowledge, my idea wouldn't break something for other users
  • ... the documentation does not mention anything about my idea
  • ... there are no open or closed issues that are related to my idea

Description

I have a big project that contains the too many graphqls, SchemaClassScanner takes 5 minutes to execute

Use Cases

I added some logs in method scanForClasses,This is my log output

SchemaClassScanner.kt:84 - Schema scan discover Query field 5611, time elapsed 83960ms
SchemaClassScanner.kt:85 - Schema scan discover Mutation...
SchemaClassScanner.kt:88 - Schema scan discover Mutation field 16461, time elapsed 218258ms
SchemaClassScanner.kt:89 - Schema scan discover Subscription...
SchemaClassScanner.kt:92 - Schema scan discover Subscription field 0, time elapsed 0ms
SchemaClassScanner.kt:94 - Schema scan Queue
SchemaClassScanner.kt:108 - Schema scan Queue time elapsed 4470ms

I tried to solve this problem using parallel stream

  • modify the line to type.getExtendedFieldDefinitions(extensionDefinitions).parallelStream().forEach { field ->

type.getExtendedFieldDefinitions(extensionDefinitions).forEach { field ->

  • modify the line to private val queue = Collections.synchronizedSet(linkedSetOf<QueueItem>())

private val queue = linkedSetOf<QueueItem>()

The performance has been improved after the modification

Schema scan discover Query...
Schema scan discover Query field 5611, time elapsed 27539ms
SchemaClassScanner.kt:86 - Schema scan discover Mutation...
Schema scan discover Mutation field 16461, time elapsed 69114ms
Schema scan discover Subscription...
Schema scan discover Subscription field 0, time elapsed 0ms
SchemaClassScanner.kt:109 - Schema scan Queue time elapsed 4403ms

But, I failed to startup, and I found a lot of the following information in the log

Schema type was defined but can never be accessed, and can be safely deleted: XXX
...
Resolver was provided but no methods on it were used in data fetchers and can be safely deleted: XXX
...

I just want to improve the startup speed, what do you any suggestions?

@coolbeevip coolbeevip changed the title Parallel get extensionDefinitions Parallel get extended field definitions Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant