tmux icon indicating copy to clipboard operation
tmux copied to clipboard

perf: batch tmux show-options

Open vdbe opened this issue 1 year ago • 1 comments
trafficstars

Batching tmux show-options gives a significant start uptime decrease of up to 1.9 (1.5 to 1.8 avg I think) under linux.

On the bash version used by macos this however seems to have a negative impact. This was test in docker with as image bash:3.2.57-alpine3.19. The negative impact maybe from docker/alpine since in bash:5.1-alpine3.19 it also had a negative impact but less. Can anyone on macos see what the real effect is?

I think the the complexity increase is worth it if the "macos"/old bash/alpine hit is because of alpine, but would love to get more feedback on this.

  • Example config 1 Screenshot from 2024-06-26 14-36-07 Screenshot from 2024-06-26 14-38-18

  • Example config 2 Screenshot from 2024-06-26 14-46-40 Screenshot from 2024-06-26 14-49-36

  • Example config 3 Screenshot from 2024-06-26 15-02-22 Screenshot from 2024-06-26 14-55-32 Screenshot from 2024-06-26 15-00-25

vdbe avatar Jun 26 '24 13:06 vdbe

1.28+ with ./window and ./pane. ./status is harder since it's not always loaded

Screenshot from 2024-06-26 13-25-20

vdbe avatar Jun 26 '24 13:06 vdbe

I have been using this PR for 2 weeks now and everything seems to work.

Would love to have the performance increases/decreases from other people/platforms so we can make a better decision on including this or not.

The bash script below will 'benchmark' this PR and the main branch using hyperfine if installed (more accurate/useful data) and time if not. It needs to be ran when inside a tmux pane/window. It would be really helpful if you could run this and comment the output/result (and if it's linux/macos/wsl/...).

#!/usr/bin/env bash

# Clone both repositories/branches
git clone --depth=1  https://github.com/catppuccin/tmux.git catppuccin-tmux
git clone --depth=1 --branch perf/batch-tmux-show https://github.com/vdbe/catppuccin-tmux.git catppuccin-tmux-batch

# Print bash and tmux version
echo "bash: ${BASH_VERSION}"
echo "tmux: $(tmux -V)"

# Benchmark
if command -v hyperfine 
then
  # hyperfine is installed
  hyperfine --warmup 3 -N ./catppuccin-tmux/catppuccin.tmux ./catppuccin-tmux-batch/catppuccin.tmux
else
  # hyperfine is not installed just using sleep
  echo ./catppuccin-tmux/catppuccin.tmux
  time ./catppuccin-tmux/catppuccin.tmux
  echo ./catppuccin-tmux-batch/catppuccin.tmux
  time ./catppuccin-tmux-batch/catppuccin.tmux
fi

benchmark.bash.txt

Example outputs
bash: 5.2.26(1)-release
tmux: tmux 3.4
./catppuccin-tmux/catppuccin.tmux

real	0m0.450s
user	0m0.231s
sys	0m0.183s
./catppuccin-tmux-batch/catppuccin.tmux

real	0m0.263s
user	0m0.144s
sys	0m0.110s
bash: 5.2.26(1)-release
tmux: tmux 3.4
/nix/store/9hv3swqri0zg5iqaw0v4mxsycxc5vgbb-hyperfine-1.18.0/bin/hyperfine
Benchmark 1: ./catppuccin-tmux/catppuccin.tmux
  Time (mean ± σ):     399.6 ms ±   3.0 ms    [User: 221.4 ms, System: 157.6 ms]
  Range (min … max):   396.6 ms … 406.4 ms    10 runs

Benchmark 2: ./catppuccin-tmux-batch/catppuccin.tmux
  Time (mean ± σ):     244.1 ms ±   2.3 ms    [User: 131.4 ms, System: 106.2 ms]
  Range (min … max):   241.7 ms … 248.5 ms    12 runs

Summary
  ./catppuccin-tmux-batch/catppuccin.tmux ran
    1.64 ± 0.02 times faster than ./catppuccin-tmux/catppuccin.tmux

vdbe avatar Jul 09 '24 11:07 vdbe

On macOS:

bash: 5.2.26(1)-release
tmux: tmux 3.4
/etc/profiles/per-user/uncenter/bin/hyperfine
Benchmark 1: ./catppuccin-tmux/catppuccin.tmux
  Time (mean ± σ):     230.6 ms ±  43.4 ms    [User: 87.4 ms, System: 90.1 ms]
  Range (min … max):   209.6 ms … 343.2 ms    10 runs

  Warning: The first benchmarking run for this command was significantly slower than the rest (343.2 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.

Benchmark 2: ./catppuccin-tmux-batch/catppuccin.tmux
  Time (mean ± σ):      99.8 ms ±  38.7 ms    [User: 38.6 ms, System: 41.8 ms]
  Range (min … max):    88.4 ms … 228.7 ms    13 runs

  Warning: The first benchmarking run for this command was significantly slower than the rest (228.7 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.

Summary
  ./catppuccin-tmux-batch/catppuccin.tmux ran
    2.31 ± 1.00 times faster than ./catppuccin-tmux/catppuccin.tmux

uncenter avatar Jul 09 '24 12:07 uncenter