Skip to content

Performance issues on linux systems #79

@Cowboy-coder

Description

@Cowboy-coder

For some time we have noticed that our test suite we are running takes like 19x longer to run on linux systems and the bottleneck seems to be in Mongolian when doing inserts.
To test this we wrote a single test-file that we run on different systems

On OS X it takes 5-7 ms
On Linux systems it takes 42-43ms

First run will not give a reliable result (because it needs to create the collection and the database and such). In our result posted above the first run is ignored

var Mongolian = require("mongolian")

// Create a server instance with default host and port
var server = new Mongolian

// Get database
var db = server.db("blog")

// Get some collections
var posts = db.collection("posts")
var comments = db.collection("comments")

startTime = new Date()
// Insert some data
posts.insert({
    pageId: "hallo",
    title: "Hallo",
    created: new Date,
    body: "Welcome to my new blog!"
}, function(err, post){
    console.log("time to insert (ms): ", (new Date()) - startTime);
    process.exit();
})

Since this seems to be very similar to this issue for node-mongodb-native https://github.com/christkv/node-mongodb-native/issues/445 I tried to apply the exact same patch (switch new Socket() to net.createConnection() ) and that actually seems to solve the issue.

We got the same result for the test file above (5-7ms) in both OS X and Linux and our test suite went from ~19 seconds down to ~660ms on Linux systems. The performance on OS X was unaffected.

I could probably write a pull request for this but I prefer if this is fixed by you (@marcello3d) because It seems like lib/connection.js will need some refactorings in order to use net.createConnection().

Anyway... let me know what you think!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions