Merge pull request #207 from pavel-paulau/master

stats struct refactoring
Some memory optimizations for reading channel logs

Generate less garbage by skipping over unwanted entries in the binary-
encoded form without allocating structs for them.
Also made the readString call more memory-efficient.
Use json.Encoder to marshal directly to output stream when possible

This generates less garbage than using json.Marshal to create a []byte
and writing that to the output.
More changes-feed optimizations

* When querying 'changes' view, set endkey equal to the channel-log's
  'since', to avoid fetching rows already in the channel-log.
* Increase the view page size from 200 to 1000.
* In normal/longpoll feed, don't flush the output stream after entries.
CBLT-82:  modify for jenkins environment

Change-Id: I1feb290b21e000707d52fa2b61659f261aa7c3e3
Yet another changes-feed optimization.

(I missed this one in my previous commit...)
For #208
Added profiling web API using net/http/pprof package

Use -profileInterface command-line arg, or set ProfileInterface top-
level config property, to start an HTTP listener that can be accessed
directly by the Go pprof tool.
For details see http://golang.org/pkg/net/http/pprof/
Changes feed: Do nothing more efficiently if nothing's changed

If nothing's changed in the database since a channel's 'since' parameter,
do nothing, not even fetching the channel log. This will help in the
steady-state puller case where it's just waiting until the next change.
(For #205)
CBLT-82:  want couchbase-sync-gateway_0.0-7_macosx-x86_64.tar.gz

Change-Id: I2e1a4691b05d066f69ba0a18fc9719d696d484b2
CBLT-82:  Merge: also build for macosx, as a tarball, on any node

* exp-plabee-002:
  CBLT-82:  want couchbase-sync-gateway_0.0-7_macosx-x86_64.tar.gz
  CBLT-82:  modify for jenkins environment
go-couchbase memory leak fix: Reuse and cleanup timer for pool timeouts

This would cause a lot of memory bloat for apps that want to grab
connections frequently.

Fixes #208
Updated go-couchbase: Added some error logging to TapFeed

Trying to diagnose some recent “TAP connection lost” errors reported in
#95.
Increase max memcached request size to 10M bytes

This prevents connection failures in the tap feed when attachments over
1MB in size are saved.
Fixes #210.
Giving illegal channel name should respond 400, not 500 (nor a warning)
REST: Allow ?rev query or If-Match header as alternative to _rev property

The CouchDB API supports these. They’re convenient for clients that want
to use HTTP to update documents but in a more generic RESTful way
without having to know about the magic “_rev” property.
Updated gomemcached
Use correct default in call to Incr, and warn about errors from it

Troubleshooting #214.
More validation/logging for corrupt channel-logs. Also, Don’t Panic.

For #212
Keep calm & carry on if channel-log doc is corrupt. But delete it.

Same as the last commit but more so. For #212 / #213
Diligently check all I/O errors, & catch all panics, in DecodeChangeLog.

For #212 and #213