Fix addpath selection performance 30/78530/22
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Dec 2018 23:30:33 +0000 (00:30 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 12 Dec 2018 10:44:14 +0000 (10:44 +0000)
commit5f21828fbabf0e8485e182c6a34a71eb4710ea2f
tree6804f475cac7f4d5881ee7d77272e7884f1bdb58
parentb364774c7a58eee5ded30bd28eecbf6e784e313c
Fix addpath selection performance

As it turns out, the two selection modes operate under completely
different assuptions, rendering
AddPathAbstractRouteEntry.selectBest() utterly useless.

Specialize N-path and All-path selectors to operate in the offset
order, which makes it clear OffsetMap.getRouteKeys() is unneeded
and that a simple offset-based helper,
AddPathAbstractRouteEntry.processOffset() is all that we need to
efficiently select paths.

Also switch N-path to use int, which is more than enough to cover
the uint8 range we really need.

The end result is that we make minimal memory allocations to
fulfill the needed functionality while also improving access
locality, while side-stepping offsetOf() searches.

For bonus points, we get to completely hide RouteKey, OffsetMap,
the AddPathBestPath constructor and all AddPathAbstractRouteEntry
fields.

Change-Id: Ia68cd3f88aef04a04506f3a2cc96d04485c19ad9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathBestPath.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/OffsetMap.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/RouteKey.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/all/paths/AllPathsRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/AddPathBestNPathSelection.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/n/paths/NPathsRouteEntry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/OpenConfigMappingUtil.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/OpenConfigMappingUtilTest.java