Introduce sparse flows and masks, to reduce memory usage and improve speed.
authorBen Pfaff <blp@nicira.com>
Tue, 4 Sep 2012 19:43:53 +0000 (12:43 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 4 Sep 2012 19:43:53 +0000 (12:43 -0700)
commit5cb7a798405c6ccc07bf9a932b709643c072b086
tree104180a227956c59898e28ea15d2b6fcd03b81cc
parent9879b94f4381a342c66489dae3b4d4150d0dce6b
Introduce sparse flows and masks, to reduce memory usage and improve speed.

A cls_rule is 324 bytes on i386 now.  The cost of a flow table lookup is
currently proportional to this size, which is going to continue to grow.
However, the required cost of a flow table lookup, with the classifier that
we currently use, is only proportional to the number of bits that a rule
actually matches.  This commit implements that optimization by replacing
the match inside "struct cls_rule" by a sparse representation.

This reduces struct cls_rule to 100 bytes on i386.

There is still some headroom for further optimization following this
commit:

    - I suspect that adding an 'n' member to struct miniflow would make
      miniflow operations faster, since popcount() has some cost.

    - It's probably possible to replace the "struct minimatch" in cls_rule
      by just a "struct miniflow", since the cls_rule's cls_table has a
      copy of the minimask.

    - Some of the miniflow operations aren't well-optimized.

Signed-off-by: Ben Pfaff <blp@nicira.com>
13 files changed:
lib/classifier.c
lib/classifier.h
lib/flow.c
lib/flow.h
lib/match.c
lib/match.h
ofproto/connmgr.c
ofproto/connmgr.h
ofproto/ofproto-dpif.c
ofproto/ofproto.c
tests/classifier.at
tests/test-classifier.c
utilities/ovs-ofctl.c