BUG 2486 : Optimizations for a single node cluster deployment 43/13943/3
authorMoiz Raja <moraja@cisco.com>
Thu, 18 Dec 2014 02:44:07 +0000 (18:44 -0800)
committerMoiz Raja <moraja@cisco.com>
Wed, 14 Jan 2015 19:37:47 +0000 (11:37 -0800)
commit887b1ccc82702af44d2bba4f3b45881410eaacf5
tree398736fe2f19df424f774a3d535d4f44ffef9e49
parenta6506ca21f257d4cbfe9312937392cf0349e3e67
BUG 2486 : Optimizations for a single node cluster deployment

The Clustered DataStore maintains an in-memory journal which contains
a list of modifications that were made to the underlying in-memory
data store. In a system with many transactions this journal will grow
and use up a lot of memory. This is what happens when we have a high
frequency writer like StatisticsManager.

The whole reason for maintaining an in-memory journal is for replication.
Recovery for the most part requires only the disk journal.

Since memory used by the in-memory journal grows dramatically it needs
to be trimmed occasionally. We do this trimming via the snapshotting
mechanism which both trims the journal and creates a snapshot on disk.

When we do not have replication on, i.e there are no followers for a
Shard there is no need for us to maintain this in-memory journal. This
patch adds an optimization in the RaftActor where if a RaftActor(Shard)
has no followers any entry that is persisted to the journal is immediately
removed by snapshotting. However since the only reason we are snapshotting
is to trim the log we do not need to go through the usual snapshotting
mechanism which creates a serialized version of the state in in-memory
data store and then writes it to disk. So, this patch does a further
optimization by fake snapshotting. Fake snapshotting just increments the
snapshotIndex in the in-memory journal - this helps when occasionally
we do the real snapshotting.

When we have no replication and no persistence a further optimization
can be done which is to completely ignore writing (or) maintaining an
in-memory journal. This means that when a commit comes through we
immediately apply the modification made by that transaction to the
state.

With these optimizations in-place the memory usage of the controller is
well in-line with what one would see with the in-memory data store. The
performance will not quite be there because of the additional queues
and executors that a Clustered Data Store transaction has to go through.

Change-Id: I4db056e26ea48f342ec2c5a934a3ad15f52cca0f
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java