From 19b54659b3203557c9ae55e51d05598cdf57f71d Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 6 Jun 2015 03:44:24 +0200 Subject: [PATCH] BUG-3157: performance tuning - Use a TrieMap as the ConcurrentMap implementation TrieMap is space-optimized and has a high fanout, which means it will reclaim space when not needed and has shallower structure than a ConcurrentHashMap. It also re-hashes automatically and concurrently. Change-Id: I1e40dbb5588c1e42475e12d73f7cadf46b909594 Signed-off-by: Robert Varga (cherry picked from commit 5faeb7ea76404e4da3620e63432b6038800d4de7) --- openflowplugin-impl/pom.xml | 4 ++++ .../impl/registry/flow/DeviceFlowRegistryImpl.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openflowplugin-impl/pom.xml b/openflowplugin-impl/pom.xml index f5edb1e3e0..8b6cad7ae6 100644 --- a/openflowplugin-impl/pom.xml +++ b/openflowplugin-impl/pom.xml @@ -132,6 +132,10 @@ org.apache.commons commons-lang3 + + com.github.romix + java-concurrent-hash-trie-map + junit diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java index 16e5ce9ad5..e34b829269 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java @@ -7,11 +7,11 @@ */ package org.opendaylight.openflowplugin.impl.registry.flow; +import com.romix.scala.collection.concurrent.TrieMap; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; @@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory; public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { private static final Logger LOG = LoggerFactory.getLogger(DeviceFlowRegistryImpl.class); - private final ConcurrentMap flowRegistry = new ConcurrentHashMap<>(); + private final ConcurrentMap flowRegistry = new TrieMap<>(); @GuardedBy("marks") private final Collection marks = new HashSet<>(); -- 2.36.6