Split defragmenter into multiple files

... to facilitate unit testing.

Change-Id: I2ab1376d7616db3a63433b82a3e6770a30d22d02
Reviewed-on: http://review.couchbase.org/44285
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Dave Rigby <daver@couchbase.com>
Defragmenter performance test

Create a new ep-engine unit test to measure the speed of the
defragmenter.

Change-Id: I809a24906596ee521402f41c68605531a3301e8e
Reviewed-on: http://review.couchbase.org/44286
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Dave Rigby <daver@couchbase.com>
Defragmenter: Reduce usage of gethrtime()

The defragmenter task calls gethrtime() after each visit to check if
it has yet reached the time limit for a chunk of
defragmentation. However, gethrtime() can be an expensive call,
especially in virtualized environments.

Add a ProgressTracker class to the Defragmenter, which monitors the
rate at which the defragmenter is visiting items and hence only makes
call to gethrtime() occasionally. This increases the rate at which
items can be visited - on AWS (c3.4xl) increases the visted rate from
3.3M items/sec to 5.6M items/sec.

Change-Id: Icbde89236cf358693ff14857b77f6eaf83119e28
Reviewed-on: http://review.couchbase.org/44354
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Dave Rigby <daver@couchbase.com>
Fix WIN32 build failure in defragmenter_test

Windows doesn't have setenv(), so use putenv() instead.

Change-Id: I1ec849b0b7a7112b37620a4de5c37f0499a0640d
Reviewed-on: http://review.couchbase.org/44508
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-12067: Enable defragmenter task by default

Change-Id: I7c342aeb306332b7ab389db18f457453c6506e1a
Reviewed-on: http://review.couchbase.org/44423
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Dave Rigby <daver@couchbase.com>
MB-12540: Refactor the way we track snapshot start/end seqnos

For the 3.0 release I needed to add snapshot sequence number
quickly and in doing so implemented an approach that was not
very good and prone to errors. The correct approach is to track
sequence numbers on disk and also to track them for each checkpoint
in the checkpoint manager. This change moves us to the better
approach.

Change-Id: Ifbdd6c87b06767ff8c6504c1058ce11195fa2428
Bug fix

Change-Id: I73f42067ea10c63d62a796799d1c036f632ceb8a