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

Slow performance, high CPU usage #144

Closed
niutech opened this issue Jul 18, 2018 · 12 comments
Closed

Slow performance, high CPU usage #144

niutech opened this issue Jul 18, 2018 · 12 comments
Labels

Comments

@niutech
Copy link
Contributor

niutech commented Jul 18, 2018

I am running a Docker version of browsh and it is painfully slow and uses almost 100% of my Intel Xeon CPU E5-2650L v4 @ 1.70GHz.

htop

Please improve browsh performance.

@tobimensch
Copy link
Collaborator

tobimensch commented Jul 18, 2018

One of the keys to improving browsh's performance is to have enough free memory. From your screenshot it can be seen that your system is already swapping.

Browsh definitely has room for performance improvements. However much of that would entail a rewrite and intense development for months.

  1. Instead of using a webextension, Browsh could be built directly on top of the code and libraries of firefox or chrome. This would cost a lot of development hours and it would have a steep learning curve. This is a next generation project, which certainly won't happen unless a developer comes along who invests a lot of time, or people donate to @tombh specifically for that reason.

  2. The webextension itself could be made more efficient. It's not really the priority right now, as there are still a lot of bugs that should be fixed before trying to optimize stuff. One way to improve the webextension would be to use more best-guess algorithms for detecting visibility. Another would be to use more lazy-loading, which means to send to the client/interfacer/server only the parts of the website that must be shown now and to not render any more than that.

  3. Better caching especially for the tty client could help to save both bandwidth and resources. See Implement a client side caching mechanism #48

Browsh as it's currently designed will never be as memory or cpu friendly as lynx, links or w3m. This is because browsh reuses full desktop browser engines with all their complexities, so the memory requirements of Browsh will never be below what a typical firefox or chrome instance would need.

I'm sure there are some improvements which can be had in the short term, I especially think about caching and lazy loading mechanisms and more efficient algorithms in the webextension.

I'm running browsh with much success on a server with 1GB RAM, 2x Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz and SSD disk space. It's an OpenVZ based Debian Jessie system.

Occasionally I must free some RAM, so that browsh can run better, therefore I can completely understand why you opened this issue. Just wanted to provide some background.

@niutech
Copy link
Contributor Author

niutech commented Jul 18, 2018 via email

@tobimensch
Copy link
Collaborator

@niutech
Yes, that could be. Which URL did you open when the slowing down happened? Or is it happening for all URLs?

@tombh
Copy link
Member

tombh commented Jul 18, 2018

Well answered @tobimensch, thanks!

The most CPU intensive thing that Browsh seems to struggle on, is parsing large, frequently changing frames. So I'm going to guess that the URL is maybe a video page? Oh, actually, the same would happen if there is a lot of scrolling on a terminal with a large size, say over 300x100 cells.

@niutech
Copy link
Contributor Author

niutech commented Jul 18, 2018 via email

@tombh
Copy link
Member

tombh commented Jul 18, 2018

And how big is your terminal?

@niutech
Copy link
Contributor Author

niutech commented Jul 18, 2018 via email

@tobimensch
Copy link
Collaborator

@niutech
Is it still slow when you reduce the size to 172x43 or something like that?

@tombh
Copy link
Member

tombh commented Jul 19, 2018

I just had another idea. What about increasing the small_pixel_frame_rate value in Browsh's config? Note that the config file was only introduced in v1.4.0

@tombh tombh added the question label Jul 19, 2018
@tombh
Copy link
Member

tombh commented Aug 4, 2018

Closing as there's been no new updates in a while. Happy to revisit if there is new info.

@tombh tombh closed this as completed Aug 4, 2018
@diggerdu
Copy link

diggerdu commented Dec 13, 2018

@tobimensch High cpu usage is not browsh's fault, most of terminal emulators are not gpu-accelerated. GPU-enabled terminals(Alacritty) will resolve this issue.

过高的CPU占用率是因为大部分终端模拟器没有使用GPU加速渲染,通过使用具有GPU加速功能的终端模拟器(Alacritty)可以解决这一问题。

@niutech
Copy link
Contributor Author

niutech commented Dec 13, 2018

Alacritty still does not resolve high CPU usage. See the screenshot:

browsh-alacritty

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

No branches or pull requests

4 participants