MB-11067: Allocate ilist on demand.

The itemlist member of the connection object is only used for TAP/UPR
connections. Therefore stop allocating memory for it up front for all
connections, and instead just allocate when a connection first tries
to use it.

Change-Id: Ia3ebeb94154d5f3ef127f26c901b10a744133c34
Reviewed-on: http://review.couchbase.org/38654
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Add iovused_high_watermark stat

New statistic which tracks the highest value of iovused - number of
iovecs used in a sendmsg().

Change-Id: I1d1a24477d94d39785ad11ae3f4c8ae8ff30a8d6
Reviewed-on: http://review.couchbase.org/38670
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11067: Reduce initial IOV list size to 10

Measuring the high watermark of how many iov elements are used for
sendmsg(), we find that during beer-sample load and pillowfight tests,
the highest used number of IOVs is only 5 (2-node cluster, replication
enabled).  Running a TAP backup this increases to 20.

Therefore (significantly) reduce the current initial size of 400 down
to 10 - normal KV connections are unlikely to need to resize any
larger, and TAP connections will only need to resize once.

Similary, reduce the high watermark for buffer shrinking from 600 down
to 50.

This brings the size of a connection object down to 1552 bytes.

Change-Id: Id6d2d96cc94f2ec64ab8f9083abc033dcaa4d82a
Reviewed-on: http://review.couchbase.org/38671
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Add msgused_high_watermark

New statistic which tracks the highest value of msgused - number of
msghdr elements used in the msglist array

Change-Id: I4585f2088d461bf8bf5c7031a411ca7f87006bba
Reviewed-on: http://review.couchbase.org/38679
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11067: Reduce initial msghdr list size to 5

Measuring the high watermark of how many msglist elements are used for
sendmsg(), we find that during beer-sample load and pillowfight tests,
the highest used number of IOVs is only 4 (2-node cluster, replication
enabled). This stays the highest for TAP and UPR backup, and for rebalance.

Therefore reduce the current initial size of 10 down to 5 - From what
I can observe this should be sufficient for most connections, not
requiring any expansion (which is handled if necessary by
add_msghdr().

Similary, reduce the high watermark for buffer shrinking from 100 down
to 20.

This brings the size of a connection object down to 1312 bytes.

Change-Id: I38d10dad8c46a6880b60acabe6b654a40fdcb756
Reviewed-on: http://review.couchbase.org/38680
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Move more connection-related code into connections.{c,h}

More general cleanup / rearrangement - move a bunch of
connection-related code into seperate files for better modularity.

Change-Id: I4d51298a5942afaebbc67a50856813a410044f40
Reviewed-on: http://review.couchbase.org/39017
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Don't respond to a buffer ack unless there is an error

Change-Id: I751d387c3ece85574610dc0b8f4542506b509f89
Reviewed-on: http://review.couchbase.org/38993
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11066: Remove up-front connection allocation, allocate on-demand

Instead of defining a statically-sized array of maximum number of
connections, simply allocate connections on demand when needed. Add an
intrusive linked-list to track them (for destruction purposes). Also
remove the pre-allocation of connections.

This paves the way for supporting dynamic modification of the maximum
number of connections.

Change-Id: I7a675ecc940f5cfb357064dc2c1c2d3b8057796d
Reviewed-on: http://review.couchbase.org/39018
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Merge remote-tracking branch 'membase/3.0'

* membase/3.0:
  Don't respond to a buffer ack unless there is an error

Change-Id: I7c07edb70e6fadef6144a283c4a2bc7669f1c335
Merge remote-tracking branch 'membase/3.0.1'

* membase/3.0.1:
  MB-11066: Remove up-front connection allocation, allocate on-demand
  Don't respond to a buffer ack unless there is an error
  Move more connection-related code into connections.{c,h}
  MB-11067: Reduce initial msghdr list size to 5
  Add msgused_high_watermark
  MB-11067: Reduce initial IOV list size to 10
  Add iovused_high_watermark stat
  MB-11067: Allocate ilist on demand.

Change-Id: Icbce6f645258d751b1092c5228f2b8b2a5ccd8e2