Raven DB 3.5: Fine Grained Work Control
With Raven DB 3.5, we've brought an improved RavenThreadPool (RTP) including better and faster indexing to better handle the unique needs of RavenDB.
Join the DZone community and get the full member experience.Join For Free
with ravendb 3.5, we are focusing on performance as one of the key features. i’ve already spoken at length about the kind of changes that we had made to improve performance. a few percentage points here and there end up being quite significant when you add them all together.
but just sanding over the rough edges isn’t quite enough for us. we want to have a major impact, not just an avalanche of small improvements. in order to handle that, we needed to be much more aware of how we are making use of resources in the system.
the result of several months of work is now ready to enter into performance testing, and i’m quite excited about it. but before i show you the results, what is it? well, ravendb does quite a lot in the background, to avoid holding up a request thread when you are calling ravendb. this mean that we have a lot of background work, indexing, map/reduce, etc.
we have been using the default .net thread pool for a long time to do that, and it has served us very well. but it is a generic construct, without awareness of the unique needs that ravendb has. therefore, we worked for quite some time to create our own thread pool that match what we do.
the major changes with the raventhreadpool (rtp from now) are:
- there is a fixed (and dedicated) number of threads that will do the work, sharing (and stealing) work among themselves.
- indexes tasks are continuous and shared, so a big indexing work will spread across all threads, but with a preference for locality of work if we have a lot of stuff to parallel.
- a slow index doesn’t stop us from working on other indexes, we’ll let it process on its own, and let the other indexes run forward without it.
- dynamic adjusting of the amount of work that is allowed for the indexes means that under load, we can dynamically and rapidly reduce the amount of work we are doing to allow more resources for processing requests.
there are other stuff, but they are mostly of interest for the people who work on ravendb, not on those who use it.
and the results, they are pretty good. here is the before and after sample.
note that we have a mix here of various types of indexes. the x axis is time, and the y axis is the number of documents indexed.
as you can see, in the before (without rtp), we are processing all indexes roughly on the same course, with a pretty flat growth over time. however, with rtp, the situation is different. you can see that very quickly the fast indexes are starting to outpace both their version without rtp and the slower indexes.
that, in turn, means that they complete much faster. in the case of the simple map index, it complete indexing roughly 50% faster than without rtp. but even more interesting is what happens globally, because we are able to complete indexing of the fast indexing fast, it means that we can process the slow index (heavymapreduce) with more resources. so even this slowpoke completes about 15% faster with rtp than without it.
we are still running tests, but even so, this is quite exciting.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.