apernet / hysteria

Hysteria is a powerful, lightning fast and censorship resistant proxy.
https://v2.hysteria.network/
MIT License
14.75k stars 1.65k forks source link

Adjusting minAckRate gets low speeds #831

Open Azuresonance opened 10 months ago

Azuresonance commented 10 months ago

(I am unsure if this is a bug) When I told hysteria to log the ack rates, I found that it is abysmally low (at 34%) and was "clamped" to 0.80.

So I dig the source code and found that the "minAckRate" constant in brutal.go seem to be the limiter.

Once I set this to a reasonable value (like 0.3 or 0.5) to account for my loss rates, and recompiled the program, I got really low speeds, a few KB/s.

Is this expected? Why does the speed plummet as I adjust this value?

tobyxdd commented 10 months ago

ACK rate of 34% means that for every 10 packets only 3-4 packets can get through. I'm surprised that QUIC can work at all. You sure you are not setting the bandwidth values wrong or something?

Azuresonance commented 10 months ago

ACK rate of 34% means that for every 10 packets only 3-4 packets can get through. I'm surprised that QUIC can work at all. You sure you are not setting the bandwidth values wrong or something?

Yes I am pretty sure. The link into China is really bad these days. In fact, I tried to lower the bandwidths to 1/3 of my actual bandwidth, and this phnomenon still persists.

I have observed that the protocol works just fine if the minAckRate is anywhere above 0.5, but once it gets to 0.5, it breaks down. I am hypothesizing that maybe the brutal algorithm has some internal unanticipated problems when the send rate needs to be doubled to compensate for ack rates below 50%. In other words, "double" might be a critical point for this algorithm, and it seem to only work for 1.x multipliers.

Like I said, I observed this phenomenon regardless of my bandwidth settings. That is, if I set the bandwidth to 1/3 my actual bandwidth, and set minAckRate to 0.3 or 0.5, it would still fail.

Any insight would be hugely helpful!

tobyxdd commented 10 months ago

There is really no scientific reason why we set the minAckRate to 0.8. It's just a "safety measure" to prevent the send rate from drifting too far away from what the user has set.

As for your case, I think the problem is less about sending packets faster or slower, but any reliable protocol can hardly work with such an abysmally low ack rate, as it will severely affect resends and control frames. You might have better luck with something that does FEC, such as kcptun.