When we creating the first subfacet within a facet, we know that there cannot be an existing subfacet with the same key, so we can skip the search through the ofproto's table of subfacets.
This is a small optimization, but it should not affect the flow setup rate in most benchmarks, because in the stressful situations that benchmarks create, OVS does not set up flows. Signed-off-by: Ben Pfaff <b...@nicira.com> --- ofproto/ofproto-dpif.c | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 95195a3..1c57196 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -4242,20 +4242,24 @@ subfacet_create(struct facet *facet, enum odp_key_fitness key_fitness, uint32_t key_hash = odp_flow_key_hash(key, key_len); struct subfacet *subfacet; - subfacet = subfacet_find__(ofproto, key, key_len, key_hash, &facet->flow); - if (subfacet) { - if (subfacet->facet == facet) { - return subfacet; + if (list_is_empty(&facet->subfacets)) { + subfacet = &facet->one_subfacet; + } else { + subfacet = subfacet_find__(ofproto, key, key_len, key_hash, + &facet->flow); + if (subfacet) { + if (subfacet->facet == facet) { + return subfacet; + } + + /* This shouldn't happen. */ + VLOG_ERR_RL(&rl, "subfacet with wrong facet"); + subfacet_destroy(subfacet); } - /* This shouldn't happen. */ - VLOG_ERR_RL(&rl, "subfacet with wrong facet"); - subfacet_destroy(subfacet); + subfacet = xmalloc(sizeof *subfacet); } - subfacet = (list_is_empty(&facet->subfacets) - ? &facet->one_subfacet - : xmalloc(sizeof *subfacet)); hmap_insert(&ofproto->subfacets, &subfacet->hmap_node, key_hash); list_push_back(&facet->subfacets, &subfacet->list_node); subfacet->facet = facet; -- 1.7.2.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev