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

perf(document+schema): small optimizations to make init() faster #14383

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

vkarpov15
Copy link
Collaborator

Re: #14113

Summary

Without this change:

$ node gh-14113.js 
6.12.6
mongoose spendTime: 24358 average: 48.716
$ node gh-14113.js 
6.12.6
mongoose spendTime: 24956 average: 49.912
$ node gh-14113.js 
6.12.6
mongoose spendTime: 25182 average: 50.364

With this change:

$ node gh-14113.js 
6.12.6
mongoose spendTime: 24003 average: 48.006
$ node gh-14113.js 
6.12.6
mongoose spendTime: 24222 average: 48.444
$ node gh-14113.js 
6.12.6
mongoose spendTime: 24247 average: 48.494

Seems like a small difference, but if you remove init entirely the average goes down to about 47.5, so this is actually a fairly significant speedup of init(). I'm assuming that the rest of the relatively small performance degradation in Mongoose 5 and 6 is due to bson slowdowns discussed in #13456.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but i will hold-off on approving until the main 6.x branch does not have failing tests anymore

@vkarpov15 vkarpov15 added this to the 6.12.7 milestone Mar 1, 2024
@vkarpov15 vkarpov15 merged commit d14d25b into 6.x Mar 1, 2024
34 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14113-2 branch March 1, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants