-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongoose 6.3.6 Performance slowdown #11919
Comments
There are not many changes from 6.3.5 to 6.3.6 Can you try to determine which one of the changes in the lib/*.js files resulted in the higher memory consumption? |
Welcome @nikosszzz We can't reproduce the whole system you have with discord bot and mongoose. Can you modify the script below to make it demonstrate the issue you're facing? 11919.js'use strict';
const mongoose = require('mongoose');
const assert = require('node:assert');
run().catch(console.error);
async function run() {
const startAt = Date.now();
await mongoose.connect('mongodb://localhost:27017/test');
const connectedAt = Date.now();
const millisecondsToConnect = connectedAt - startAt;
console.log(millisecondsToConnect);
assert.equal(millisecondsToConnect < 40, true);
const mongoServerVersion = await getMongoServerVersion();
console.log(mongoServerVersion);
console.log(mongoose.version);
console.log('All assertions passed.');
}
async function getMongoServerVersion() {
const MongoAdmin = new mongoose.mongo.Admin(mongoose.connection.db);
const info = await MongoAdmin.buildInfo();
const mongoServerVersion = info.version;
return mongoServerVersion;
} Output
The connection time is consistent for me: 10~35 milliseconds for both versions. |
Perhaps this is some issue with the default TSC compiler I use for my TypeScript discord bot? When I use SWC as the compiler, it is completely fine and way faster. |
What version of MongoDB are you using? What operating system are you using as well? Can you move the assertions to the bottom of the function so the logs show up? await mongoose.connect('mongodb://127.0.0.1:27017/test', { family: 4 }); |
I think it would really help if you patch in your project in node_modules/mongoose the changes you see in the link i provided and report back which of those changes resulted in the performance regression. |
I'm using Windows 11 Pro 21H1 (build 22000.708). Note: I am not connecting to a local Mongo database. I am connecting to my bot's database. |
We will probably not be able to reproduce your issue, if you dont hint which of the few changes resulted in that slowdown. Just saying that you dont get sad, when this issue will get marked as stale and then auto-closed. |
@nikosszzz try upgrading to 6.3.9. I suspect this may be due to #11898, which was released in 6.3.6 and caused a slowdown in the TypeScript compiler |
Hmmm, yes. It seems to have improved and is back to normal. |
@vkarpov15 Is #11898 a typo? How can a TS PR affect JS connection performance? |
@AbdelrahmanHafez OP is running through ts-node and reporting slow startup time. ts-node usually runs typescript compilation as part of startup. So that's my guess as to the root cause here |
I didn't notice the ts-node bit. However, running the script in #11919 (comment) calculates the time of the connection, which still demonstrates the issue, so this eliminates the possibility that this is a TS issue. However, the issue is solved now, so I think we're good. |
Prerequisites
Last performant version
6.3.5
Slowed down in version
6.3.6
Node.js version
16.14.2
馃Ε Performance issue
Hello!
The latest version of mongoose which is 6.3.6 has significantly increased my bot's start up time and increased memory usage, as you can see in this picture:
(this picture shows how long it took to import a command.)
Meanwhile with 6.3.5, the results differ alot:
As you can see it slows down the bot significantly by around 1000~ ms!
Also here is how I connect to my MongoDB database:
Steps to Reproduce
Run a discord bot with mongoose installed as a npm package and make it connect to a MongoDB database.
Expected Behavior
Should not slow down the bot in any way.
The text was updated successfully, but these errors were encountered: