Added WSL support by PastaMasta · Pull Request #86 · tmux-plugins/tmux-cpu · GitHub
Skip to content

Added WSL support#86

Open
PastaMasta wants to merge 4 commits into
tmux-plugins:masterfrom
PastaMasta:wsl-support
Open

Added WSL support#86
PastaMasta wants to merge 4 commits into
tmux-plugins:masterfrom
PastaMasta:wsl-support

Conversation

@PastaMasta

Copy link
Copy Markdown

This PR adds support to gather CPU & RAM % usage of the Windows host system when using Windows subsystem for Linux.

As the guest CPU / RAM can be limited by WSL config the current methods are not indicative of the whole system.

This also adds two new options: @cpu_wsl_host and @ram_wsl_host to control if this data should come from the guest or the host - when set the data comes from querying wmic.exe

@casperdcl casperdcl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

From my tests, it seems a bit slower (WSL2 debian on Win11):

  • CPU wmic: 1.3sec
  • CPU ps -aux: 0.3sec
  • RAM wmic: 0.54sec
  • RAM free: 0.14sec

are there any advantages to using wmic? Is it more accurate? I didn't quite understand "guest CPU / RAM can be limited by WSL config the current methods are not indicative of the whole system"

Comment thread scripts/cpu_percentage.sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to just do this?

Suggested change
if [[ $(get_tmux_option @cpu_wsl_host) == "true" && -n "${WSL_DISTRO_NAME}" ]] ; then
if command_exists "wmic.exe"; then

or even better, alter the is_cygwin function & convert pre-exisiting WMIC calls to wmic.exe?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to ensure we gave users the options if they wanted to just see the guest/WSL performance or the whole system and to make sure it only ran if you actually were inside WSL (I use the same .tmux.conf on multiple systems)

or even better, alter the is_cygwin function & convert pre-exisiting WMIC calls to wmic.exe?

This might be a better option, although cygwin and WSL are different beasts - I'll install cygwin and give it a go when I've got chance.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to install cygwin -- I mean we can change is_cygwin to simply is_win (i.e. is_wsl_or_cygwin)

@PastaMasta

Copy link
Copy Markdown
Author

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

Successfully merging this pull request may close these issues.

2 participants