Hi,
I have some commands I want to run with exec that take just a couple of ms to
output a KB or two and exitstatus (OpenSSH server). However when testing over
the network I am finding it takes a lot more than the ping time between the
systems.
Since I wanted the exitstatus for the command it seems I need a new channel
each time, so currently I have:
channel = libssh2_channel_open_session(session);
libssh2_channel_exec(channel, "echo Example");
while (libssh2_channel_read(channel, buffer, len) > 0) ...
libssh2_channel_close(channel);
libssh2_channel_get_exit_status(channel);
libssh2_channel_free(channel);
With about a 28ms ping time, "libssh2_channel_open_session" takes about 90ms,
and "libssh2_channel_exec" takes about 30ms. The rest takes less than 1ms.
I tried setting TCP_NODELAY on my socket which got the open session down to
30ms. I couldnt find any reference to setting that for libssh2 (e.g. the
examples dont do this) and am not certain if it risks creating other problems.
Is there any other performance enhancements that can be made? I am considering
pre-emptively opening channels during idle times so that I can immediately go
to libssh2_channel_exec which looks to avoid the round trips, but again its
unclear if having many unused channels is considered OK.
Thanks,
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel