ParallelSSH / ssh2-python

Python bindings for libssh2 C library.
https://parallel-ssh.org
GNU Lesser General Public License v2.1
228 stars 70 forks source link

Feature request: enable compression flag #195

Open pletnes opened 8 months ago

pletnes commented 8 months ago

Hi!

Thanks for a performant and useful SFTP implementation. Beats the other libraries I've tried out there.

Feature request: I've tried to enable compression but can't seem to find how to do it in the documentation. Reading the cython and C source code did not help me either (not a C expert though). Is this possible to do now? Or could it be implemented, and how? The files I want to transfer compress well.

(Note that the Google groups forum does not seem to exist anymore.)

enkore commented 7 months ago

You'd use LIBSSH2_FLAG_COMPRESS with libssh2_session_flag (not the greatest API for this in the world, as the protocol has flexible negotiation for this, instead of an zlib on-off switch - though to be fair, that's the only compression anyone ever implements) for this. This isn't a wrapped function in ssh2-python as far as I can tell.

This is usually not that interesting, because this is zlib, so quite slow and can be a CPU bottleneck even on modest connection speeds with the regular zlib (without QAT or zlib-ng).

pletnes commented 7 months ago

I'm currently in the "huge files which compress >50x on a beefy machine far away" corner so it's one of those cases where compression really is handy.

From what I can tell, in libssh2, this just a bitmask-style flag on the session. Any pointers to how I'd proceed on implementing this myself?

Red-M commented 7 months ago

I already have this feature in my own fork.