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

Rendering complex status on 'update-status' causing wezterm to feel slow and appear choppy #5939

Open
dylan-hoefsloot opened this issue Aug 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dylan-hoefsloot
Copy link

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20240811-112922-0ac1e948

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

When rendering a complex status bar using wezterm.on('update-status' ... input lag becomes noticeable and navigating lines looks choppy.

Commenting out this section of my config resolves the issue.

At first I thought the status bar must be taking too long to render and hence causing the slowness, however changing the status update interval to a number even as high as 10 seconds didn't change things at all config.status_update_interval = 10000

This then led me to check if status_update_interval was working as I expected. I am not sure how it is supposed to work, however changing it didn't seem to effect how long re-renders took when information changed.

My guess is that this update must be running synchronously, otherwise I would think this wouldn't be a problem.

To Reproduce

Use io.popen to run system commands in the update_status function which seems to take long enough to cause input time to suffer

Configuration

function execute(command)
  local handle = io.popen(command)
  local result = handle:read("*a"):gsub('\n', '') -- Remove newline
  handle:close()
  return result
end

function git_branch(file_path)
  return execute("git -C " .. file_path .. " branch --show-current 2>/dev/null")
end

function git_root(file_path)
  return execute("git -C " .. file_path .. " --no-optional-locks rev-parse --show-toplevel 2>/dev/null")
end

function right_status(window, pane)
  local cwd_uri = pane:get_current_working_dir()
  if cwd_uri then
    local branch = git_branch(cwd_uri.file_path)
    local root = git_root(cwd_uri.file_path)
  end
end

wezterm.on('update-status', function(window, pane)
  right_status(window, pane)
end)

Expected Behavior

Either expected this to not degrade performance or be able to specify longer status_update_interval that remedies the performance issue

Logs

Debug Overlay
wezterm version: 20240811-112922-0ac1e948 aarch64-apple-darwin
Window Environment: macOS 14.5 (23F79)
Lua Version: Lua 5.4
WebGPU: name=Apple M1 Pro, device_type=IntegratedGpu, backend=Metal, vendor=0, device=0

Anything else?

Running hyperfine to check the performance of the two git commands (although this is outside of lua and wezterm) shows they take about 3-5ms each.

This might be greater with the overhead of running them from lua, just thought it was worth mentioning

@dylan-hoefsloot dylan-hoefsloot added the bug Something isn't working label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant