-
-
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: mongodb 4.3.0 option enableUtf8Validation #11638
Labels
discussion
If you have any thoughts or comments on this issue, please share them!
Comments
IslandRhythms
added
the
discussion
If you have any thoughts or comments on this issue, please share them!
label
Apr 7, 2022
I took a look and it is possible to set the mongoose.connect('mongodb://localhost:27017/test', { enableUtf8Validation: false }); However, using the script from #11380, it doesn't look to have much impact. For the below script: const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test', { enableUtf8Validation: true });
const RECORDS_AMOUNT = 10000;
const DATA_AMOUNT = { min: 40, max: 400, };
const slowsaveSchema = new mongoose.Schema({
randomData: [String],
});
const slowsaveModel = mongoose.model('slowsave_experiment', slowsaveSchema);
let last100_count=0, last100_sum=0, total_count=0, total_sum=0;
async function addData() {
const record = new slowsaveModel();
for (let i = 0; i < Math.random()*(DATA_AMOUNT.max-DATA_AMOUNT.min) + DATA_AMOUNT.min; ++i) {
record.randomData.push(Math.random());
};
const startTime = Date.now();
await record.save();
const time= Date.now()-startTime;;
last100_count++; total_count++;
last100_sum+=time; total_sum+=time;
if (last100_count>=100) {
console.log(`l100.avg=${last100_sum/last100_count}, total.avg=${total_sum/total_count}`)
last100_count=0;
last100_sum=0;
}
};
async function main() {
for (let i = 0; i < RECORDS_AMOUNT; i++) {
setTimeout(async () => {
await addData();
}, Math.floor(Math.random()*2000 + 2000));
}
};
main(); With
With
So |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From the release notes:
Performance
The original release of the 4.x driver relied on a new version of the BSON library that enables UTF-8 validation by default, resulting in noticeable performance degradation over the 3.x driver when processing over string data. This release introduces an option to opt out of this validation by specifying enableUtf8Validation: false at the client, database, collection, or individual operation level.
https://github.com/mongodb/node-mongodb-native/releases/tag/v4.3.0
We should consider to benchmark and make it possible to set it by the implementers. Also we should consider to create a performance optimization subpage in the docs.
The text was updated successfully, but these errors were encountered: