BUG-1228: Optimize AbstractForwardedDataBroker a bit 04/9504/1
authorRobert Varga <rovarga@cisco.com>
Wed, 30 Jul 2014 18:42:00 +0000 (20:42 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 30 Jul 2014 18:57:32 +0000 (20:57 +0200)
commit2aa99b3ddb662c25490fbcbf9f65d99a6811e29a
tree06d2ac685dbff0c3d6197fcf589e55855f569084
parented693440aa741fee9b94447f8404d89b4020f616
BUG-1228: Optimize AbstractForwardedDataBroker a bit

Profiling OFP with datastore backend has revealed that we spend about 9%
of CPU in AbstractForwardedDataBroker$1.compare(). This turns out to be
a comparator, which compares two YangInstanceIdentifiers by their path
length -- and to do that it iterates fully through both of them.

We perform three optimizations:
- make the comparator itself shareable, so we do not instantiate it
  (6000 during the profiling run)
- make the .sortedEntries() smart about empty maps
- teach the comparator to abort iteration as soon as the result is
  known

At the same time we import YangInstanceIdentifier, making the code a bit
more readable.

Change-Id: I38d3629ab33dac9e2e29b092e3a89d0821d09b07
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java