-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Improve performance especially of validate and clone #11298
Conversation
I think the biggest performance bottleneck is the ES6 Proxy in DocumentArray and MongooseArray. Playing currently aroung with using WeakSets to see if the isMongooseArray and isMongooseDocumentArray can be boosted or not. Also trying to figure out if we can reduce the roundtrips through the proxy layer by using forEach etc. when iterating through the elements of those special arrays. |
@vkarpov15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of comments, but general idea looks good
} | ||
|
||
const validator = v.validator; | ||
const validatorProperties = utils.clone(v); | ||
const validatorProperties = Object.assign({}, v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little risky because Mongoose clone() does a deep clone, so this may cause issues if there's a validator with nested objects
Co-authored-by: Valeri Karpov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'll just make the clone()
change in master.
This PR improves the performance of especially validate and clone.
before:
after: