Skip to content
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

Optimization: Reduced CPU usage on bandwidth load. #22

Open
Marctraider opened this issue Nov 8, 2019 · 15 comments
Open

Optimization: Reduced CPU usage on bandwidth load. #22

Marctraider opened this issue Nov 8, 2019 · 15 comments

Comments

@Marctraider
Copy link

Optimization: Reduced CPU usage on bandwidth load.

Noticed the software is quite CPU bound, although it doesn't currently appear to give me any issues, it could maybe be beneficial for higher throughput on load).

@ale-rinaldi
Copy link
Member

Yep, I'm pretty sure CPU usage and bad throughput are really related. I never had a good enough look at this aspect, since my main usage of engarde (and the reason why I wrote it) is to reliably forward a 256Kbps audio stream across the Internet... But I think it's time to seriously work on it. Thank you

@Marctraider
Copy link
Author

I typically noticed this when I first transitioned from ARM based router to Intel NuC and my clock speed was stuck on 800Mhz due to some linux quirks. (intel_pstate vs acpi-cpufreq driver).

At first I thought it was the cumulative bandwidth with wireguard and the encryption it uses, but that doesn't seem to be the case! :)

@Marctraider
Copy link
Author

I see your comment in mail, not here though.

either way, I can sometimes sustain 175+mbps which the max my fastest connection can achieve, I assume its also drawing about 80mpbs from the two other lines, so an accumulation of 250+mbit, and at that point i'm not even sure if the application or my cpu is at its limits.

Its not a severity thing for me, but any optimization is always welcome (Mostly in regard to unable to write socket / short ping spike thingy)

No sweat :)

@ale-rinaldi
Copy link
Member

You're right, I can't see the comment here, too :/

Well, by the way I don't like it using so much CPU anyway, it's a nonsense thing for just taking UDP packets from one place and putting them in another.

For the ping issue, maybe I have a solution for it, even if I'll need your help to test it since it's not easy for me to reproduce. I'll update the relative issue as soon as I have something ready to test.

BTW, if you're finding engarde useful for your workflow, we just added a Bitcoin address for donations in the readme :)

@Marctraider
Copy link
Author

Marctraider commented Nov 10, 2019

Do you have paypal instead? I don't actually have a bitcoin wallet.

But sure, I'm more than happy to test stuff it it makes the program (and redundancy) even more efficient. You should promote this tool a bit more, It took me 2 months of screwing around before I even knew this existed, and I searched quite a lot. Could've saved me so much time :-(

Currently my setup is basically a testbed, still dealing with some usb quirks on my ethernet dongles etc, but eventually I just want it to run and keep it at that. (Until there are updates or other improvements ofcourse)

So for now I'm all yours!

@Marctraider
Copy link
Author

Edit: Made a bitcoin wallet, cheers!

@ale-rinaldi
Copy link
Member

Hi @Marctraider , wow, that's great, thank you very much! Unfortunately I'm still working on your issue, expecially regarding the latency peaks. I didn't make a test build with reduce throughput because it's simply insane: it doesn't go over 1.5Mbps and that's not a viable solution at all.

I tried different approaches about it but none of them gave the expected results: I hope to be able to find a solution soon!

Thanks again :)

@Marctraider
Copy link
Author

Marctraider commented Nov 18, 2019

@ale-rinaldi Np man, it is for the appreciation for your current code :-)

Does the 'buffer overflow' issue also happen if engarde detached a specific interface faster? In that case maybe it is more easily handled with a simple check somehow with high polling rate? To at least diminish the effects.

Seems it is now just writing to something even if it is no longer possible. No clue how this would have to be checked though.

And no, 1.5Mbps seems practically unusuable lol.

Anyway, the issue rarely ever happens, just under certain circumstances. Seems like the last culprit to solve, to make engarde truly 100% solid.

@ghost
Copy link

ghost commented May 25, 2020

I'm able to pull 25mbit/s (my internet limit) on 720mhz ar71xx Archer C7v2, will test over lan to see max, I simply compiled engarde-client with mips flag without any effort, works like a dream! Thank you dev!

My journey for usable internet from worse to best on unstable lines:
Speedify on RPi -> OpenMPTCProuter(best of all for TCP only + aggregate) -> borrowed Peplink -> Glorytun UDP (bad with packet loss, even at 1% limiter) -> ExitLag -> Engarde (no aggregation), finally done :)

Edit: And yes it spikes 100% cpu, average 75 on full speed, but with no side effect, no latency increase, no speed decrease, and even LuCI webui isn't sluggish, running stress-ng only brings the speed down to 8mbit.

@Marctraider
Copy link
Author

I also tried most of those, but non can properly handle link loss without major rubberbanding. And TCP is even worse for general internet usage and gaming/voip.

Engarde beats all those solutions for stable connection ;-)

@ale-rinaldi
Copy link
Member

Hi @TalalMash , I'm really happy you're finding engarde useful, thanks for your feedback :)

@Marctraider
Copy link
Author

Any update on this? Possible to somehow adjust code without a complete rewrite?

I wonder maybe if compiling it with more cpu specific optimizations could yield a few more megabits of throughput, but I never really compiled any GoLang stuff.

@xavierleung
Copy link

I am also curious if someone figure out any optimizations by now.

@cjangrist
Copy link

Is there a set of tests that can be run offline to triage and diagnose any CPU bottlenecking or throughput issues?

@Llorx
Copy link

Llorx commented Oct 10, 2023

I'm able to pull 25mbit/s (my internet limit) on 720mhz ar71xx Archer C7v2, will test over lan to see max, I simply compiled engarde-client with mips flag without any effort, works like a dream! Thank you dev!

My journey for usable internet from worse to best on unstable lines: Speedify on RPi -> OpenMPTCProuter(best of all for TCP only + aggregate) -> borrowed Peplink -> Glorytun UDP (bad with packet loss, even at 1% limiter) -> ExitLag -> Engarde (no aggregation), finally done :)

Edit: And yes it spikes 100% cpu, average 75 on full speed, but with no side effect, no latency increase, no speed decrease, and even LuCI webui isn't sluggish, running stress-ng only brings the speed down to 8mbit.

Hey! So Peplink is not that good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants