MongoDB and V8

Avatar for vbabiy@howsthe.com

MongoDB and V8

Published Feb. 22, 2010 by Vitaly Babiy

If you haven't heard of mongoDB, its a fast schema free document store. MongoDB uses Javascript as its query langauge, and uses a derivative of JSON called BSON for storing data. Currently the JavaScript engine used is spider monkey (Developed by Mozilla). If you checkout the lastest version of mongoDB you will be able to build it with Google's V8 JavaScript engine support. The V8 engine powers Google's new chrome browser, using this engine with mongoDB should give an amazing speed boost. This article will walk you thourgh building both V8 and mongoDB with V8 support on Ubuntu 9.10 32bit (64bit should be very similar).

First you will need to checkout the V8 engine source code. More information can be found at http://code.google.com/p/v8/. Before we checkout the code you will need a few tools and libraries.

sudo apt-get install subversion git-core tcsh git-core scons g++ libpcre++-dev
sudo apt-get install libboost-dev libreadline-dev xulrunner-1.9.1-dev

We are now ready to checkout code.

svn checkout http://v8.googlecode.com/svn/trunk/ v8
cd v8

Now all the libraries and tools are in place to build V8. There is one issue with building on Ubuntu 9.10, but there is a workaround. The details for it can be found at http://code.google.com/p/v8/issues/detail?id=574. The basic fix is to comment out -Werror in the SConstruct file. In the current trunk version that I am using its on line 270 of the SConstruct file.

266 V8_EXTRA_FLAGS = {
267   'gcc': {
268     'all': {
269       'WARNINGFLAGS': ['-Wall',
270                        #'-Werror',
271                        '-W',
272                        '-Wno-unused-parameter',
273                        '-Wnon-virtual-dtor']
274     },
275     'os:win32': {
276       'WARNINGFLAGS': ['-pedantic', '-Wno-long-long']
277     },

In order to build you run the scons command.

scons

This may take a few minutes to build, once completed we can move on to building mongoDB.

cd ..
git clone git://github.com/mongodb/mongo.git
cd mongo

You should now be in the root of the mongoDB project. From here we will be able to build the project. We will be using the same scons tool as we did with V8.

scons all --usev8

Once this process is completed, which could take a few minutes the mongodb executables will be in the current directory (mongo, mongod, etc..). When you start mongod it will be using the V8 engine.

Thats it folks enjoy mongoDB with V8 if you have any speed comparison, I would love to hear them you can post them in the comments. I plan on posting more details and some tricks on how to optimize the quires (Dates are a killer).

links:

Written By Vitaly Babiy

Avatar for vbabiy@howsthe.com

Vitaly Babiy is the creator of Howsthe.com (Yes, you can contact him about the service). He is a software engineer at heart, loves working with great technologies like Django and Jquery. Vitaly spends most of his days in python and loves it. Another passion of Vitaly's is learning the business side of things, one of the reason why he started Howsthe.com monitoring service. You can follow him on Twitter

blog comments powered by Disqus

A blog about development, marketing, and design.