The question is which capture route to ship for live streaming and agent eyes. Speed alone does not decide it, so every route now also reports producer CPU and RSS, machine CPU from /proc/stat, the compositor's own CPU, and a per-frame buffer footprint -- all sampled around the measured loop, with an idle control sample so an animating page's cost is not attributed to the capture. The baseline forks a process per frame and spends 95% of each frame waiting, so the interesting finding is not which route is faster but which one leaves the compositor able to do its job: in-process acquisition roughly halves the compositor's per-frame CPU even though the machine saturates either way.
40 lines
1.9 KiB
Nix
40 lines
1.9 KiB
Nix
{ pkgs ? import <nixpkgs> { } }:
|
|
# The spike's own environment. Deliberately NOT in the repo's main flake: the
|
|
# production flake stays free of Rust, pywayland-scanner and libjpeg-turbo
|
|
# until the verdict says which of them the winner actually needs.
|
|
let
|
|
python = pkgs.python3.withPackages (ps: [ ps.pywayland ps.cffi ]);
|
|
in
|
|
pkgs.mkShell {
|
|
packages = [
|
|
python
|
|
python.pkgs.pywayland # brings `pywayland-scanner` for the protocol bindings
|
|
pkgs.wayland # the core wayland.xml
|
|
pkgs.wayland-scanner # `wayland-scanner` itself, which pywayland-scanner shells out to
|
|
pkgs.wayland-protocols # the ext-image-copy-capture XML, staged
|
|
pkgs.libjpeg_turbo # ctypes: turbojpeg, the encoder grim itself uses
|
|
pkgs.pkg-config
|
|
pkgs.jq
|
|
pkgs.ffmpeg
|
|
];
|
|
|
|
shellHook = ''
|
|
export SPIKE_ROOT="$PWD"
|
|
export PYTHONPATH="$PWD/generated''${PYTHONPATH:+:$PYTHONPATH}"
|
|
# `lib.getLib`, not the bare package: the bare attribute resolves to
|
|
# libjpeg-turbo's *bin* output here, which has no shared library in it, and
|
|
# ctypes then fails with "cannot open shared object file" pointing at a path
|
|
# that looks right until you notice the `-bin` suffix.
|
|
export TURBOJPEG_PATH="${pkgs.lib.getLib pkgs.libjpeg_turbo}/lib/libturbojpeg.so"
|
|
export WAYLAND_DISPLAY="''${WAYLAND_DISPLAY:-/run/hypr-stream/wayland-1}"
|
|
# `wayland.xml` ships in the **wayland-scanner** package, not in `wayland`
|
|
# (whose store path is `lib` only) -- and not via pkg-config in an mkShell,
|
|
# because `packages` does not put dev outputs on PKG_CONFIG_PATH.
|
|
export WAYLAND_CORE_XML="${pkgs.wayland-scanner}/share/wayland/wayland.xml"
|
|
export WAYLAND_PROTOCOLS_DIR="${pkgs.wayland-protocols}/share/wayland-protocols"
|
|
echo "capture-speed spike env -- python $(python3 --version 2>&1 | cut -d' ' -f2)"
|
|
echo " WAYLAND_DISPLAY=$WAYLAND_DISPLAY (do NOT set XDG_RUNTIME_DIR to the same dir)"
|
|
echo " generated protocol bindings: $PWD/generated"
|
|
'';
|
|
}
|