Return back to the blog

Inside Chronon 3 Recorder: How we achieved the magical speed boost

Posted by Prashant Deva on November 9, 2012

We released Chronon 3 last week with an order of magnitude performance improvement. Let’s take a look under the hood to see what makes it all tick!

The Recipe

Look at the source code of any computer program. You can pretty much predict what it is going to do, given you had some extra info like what branch will be taken and/or what the return value of a particular method call is.


In the code below, if you knew the value of ‘a’, you could predict whether ‘even’ or ‘odd’ will be printed.


Chronon 3′s recorder follows a similar principal. It instruments the bytecode of you program as its loaded and does static analysis on it to come up with an initial set of ‘predictions’ as to how your program will behave.

Once your program is running, it keeps monitoring it against the initial set of predictions. If the execution at any time differs from what was ‘predicted’:

1. The prediction data structure is modified to take into account the new information.



2. Recording data is generated to select the right ‘prediction’ from the structure. This usually takes only 1 to 4 bits.

3. If the prediction matches accurately though then no data is generated at all!


See it in Action

For example, consider the code below:


Assume there are 2 threads that call the method process().

The first thread has an object of type Foo and calls, which matches the prediction made by the recorder exactly, so no data is generated at that point for that thread.

The second thread calls has an object of FooSub instead, and thus ends up calling

Now here is where things get interesting. For this thread only, the prediction structure is adjusted to account for this new method call. Then a single bit is stored to select the right method call from the prediction structure. The previous thread, on the other hand, which keeps keeps generating no data as its prediction is accurately matched.


As you can see that the new prediction mechanism helps in saving a ton of data that would otherwise have been generated and even when data is indeed generated, it’s only very minimal. Apart from the example given above, we have a whole bunch of predictions inside the Chronon 3 Recorder. We now even have a pluggable architecture where we can keep plugging in more of these predictions and constantly increasing the speed of the recorder, without needing to wait an entire year.

So far the current architecture has worked extremely well and almost all our previous users running into OutOfMemory issues are now able to record easily!