-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Rust std TCP set_read_TimeOut instead of a custum one ? #87
Comments
I totally agree with that. But the key is, that the underlying packet processing is performed on any trait that implements Anyway, I can do some investigation when I'm free. BRs. |
Yes, I understand, does the library support or would like another protocol than ssh over tcp? I did something experimental, I got a huge improvement in CPU usage from 100% to 0.1%. You can check with Just removing the non blocking by default and set the default timeout to 30 sec with the standard function. What do you think about ? |
Hi, And regarding your question:
The answer is Yes. Not only in the WebSocket (In plans), but also in some of my private repos I use it to playback recorded ssh traffic via bufReader |
Hey,
I would like to talk about the way you handle the timeout when reading stuff on the tcp connection.
I was wondering if it would be better to use the standard implementation for read with a timeout on TCP rather than a custum one.
https://doc.rust-lang.org/std/net/struct.TcpStream.html#method.set_read_timeout
I m asking my self if your implementation can cause an unnecessary hight CPU usage if the server respond slowly.
ssh-rs/src/model/packet.rs
Line 52 in 9f3528d
The tcp connection is set by default to non blocking :
ssh-rs/src/session/mod.rs
Line 255 in 9f3528d
So when you read
ssh-rs/src/model/packet.rs
Line 61 in 9f3528d
The read call terminates immediately if nothing is available at the moment, returning the wouldBlock error, then the loop checks the timeout and loops indefinitely until something is available in the buffer.
It might be more efficient to read only once and let the system manage the timeout ?
What do you think about ?
Because when i connect to my server, i notice an hight cpu usage from my program who use only your lib.
The text was updated successfully, but these errors were encountered: