I see. Apparently zlib calls are that costly.
Yikes! They are when you set this:
#define EC_COMPRESSION_LEVEL Z_BEST_COMPRESSION
in ECSocket.cpp (Thanks for the pointer Stu.)
That's equivalent to gzip -9 - which has a _massive_ CPU overhead for a small size gain over gzip's default level 6.
Here's what SSH's man page has to say about session compression:
-C Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11 and TCP connections). The com‐
pression algorithm is the same used by gzip(1), and the “level” can be controlled by the CompressionLevel option for protocol
version 1. Compression is desirable on modem lines and other slow connections, but will only slow down things on fast net‐
works. The default value can be set on a host-by-host basis in the configuration files; see the Compression option.
Gzip's man page says:
-# --fast --best
Regulate the speed of compression using the specified digit #, where -1 or --fast indicates the fastest compression method
(less compression) and -9 or --best indicates the slowest compression method (best compression). The default compression
level is -6 (that is, biased towards high compression at expense of speed).
After years of fiddling with long (slow) links, compression level 1 or 2 are about all I bother with even on transoceanic SSH sessions (we use SSH+rsync a lot at $orkplace to keep multi-Tb data archives up to date as well as to pull in stuff from observatories worldwide) .
There's a clear throughput penalty on local LAN with compression enabled - rsync initial sessions max out at 25-30Mb/s with it on (using i7 cpus and 8Gb+ ram) vs 60-90Mb/s with it off (disk speed is the limit with compression off on local links, vs CPU overhead with compression on)
I'm not totally dissing client-server compression - it's useful on slow links but it's always a juggling act to balance the latency+CPU overhead caused by compression vs link latency caused by uncompressed data - and care has to be taken to not try compressing data running across an already compressed link (such as a SSH tunnel, or a modem link (It's rare for modems to not include compression these days)). That's why I keep suggesting it be switchable.
Meantime I'll try setting compression to minimum (fastest) as a starting point and see how it behaves.