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

refactor(microservices): improve speed of grpc server initialization #13392

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

yjiq150
Copy link
Contributor

@yjiq150 yjiq150 commented Apr 3, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

In order to find grpc service descriptors, collectDeepServices function recursively searches whole grpcDefinitions generated by protoLoader, which currently includes all descriptors like namespace, service, and field.

What is the new behavior?

Because field descriptors cannot have namespace as their child, they don't need to be recursively searched. They can distinguished by checking existence of 'format' field and they can be skipped from the search to speed up the process.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

In the project I am working on, proto models are heavily used.
It took more than 3 seconds in M2 MacBook Pro to run collectDeepServices before the modification.
Now it takes around 300ms in the same environment after the modification

@coveralls
Copy link

Pull Request Test Coverage Report for Build 9a0d37e7-42c8-4e54-a3ae-9b3a5c95c083

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 92.125%

Totals Coverage Status
Change from base Build eacd3e56-4bed-4f5e-9bab-412a10335aab: 0.002%
Covered Lines: 6738
Relevant Lines: 7314

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit 24755d6 into nestjs:master Jun 3, 2024
3 checks passed
@kamilmysliwiec
Copy link
Member

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants