ofproto-dpif: Cache result of time_msec() for rule_expire().
authorDaniele Di Proietto <diproiettod@vmware.com>
Thu, 2 Jun 2016 02:01:10 +0000 (19:01 -0700)
committerDaniele Di Proietto <diproiettod@vmware.com>
Thu, 2 Jun 2016 20:20:56 +0000 (13:20 -0700)
commitf5857865770efb5a5383fa7aa886c0ff15f2038a
treeddc9ff55fc3cfea72ff734e985bed7cfb5a0b615
parent68da36feee8ad2eccb9371542018c6b08b5a553d
ofproto-dpif: Cache result of time_msec() for rule_expire().

In the run() function of ofproto-dpif we call rule_expire() for every
possible flow that has a timeout and rule_expire() calls time_msec().
Calling time_msec() repeatedly can be pretty expensive, even though most
of the time it involves only a vdso call.

This commit calls time_msec only once in run(), to reduce the workload.

Keeping the flows ordered by expiration in some kind of heap or timing
wheel data structure could help make this process more efficient, if
rule_expire() turns out to be a bottleneck.

VMware-BZ: #1655122
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ben Pfaff <blp@ovn.org>
ofproto/ofproto-dpif.c