ctdb-ipalloc: Optimise check to see if IP is available on a node
authorMartin Schwenke <martin@meltin.net>
Fri, 18 Nov 2016 05:08:13 +0000 (16:08 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 1 Dec 2016 23:24:28 +0000 (00:24 +0100)
commit429377a2426fdfc8c3f7d8854fa2189ad36ff78c
tree4b7f0c2754529397df40eca7cc07b88c4170e465
parent24db43839f8a17c4498454d4bbd24411f647defa
ctdb-ipalloc: Optimise check to see if IP is available on a node

Use a "bitmap" of available IPs for each IP address instead of walking
the list of available IP addresses.

For ctdb/tests/takeover/lcp2.030.sh, this improves the time taken on
my laptop from:

  real 0m11.997s
  user 0m11.960s
  sys 0m0.000s

to

  real 0m8.571s
  user 0m8.544s
  sys 0m0.000s

So, when assigning all 900 IP addresses the improvement is about 25%.

For the no-op case (where all IPs are already assigned to nodes), the
extra setup adds a small fraction of a second for 900 IPs.
Intermediate cases result in intermediate improvements.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ipalloc.c
ctdb/server/ipalloc.h
ctdb/server/ipalloc_common.c