summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2022-02-20 10:59:55 -0500
committerDan Davison <dandavison7@gmail.com>2022-02-20 11:24:27 -0500
commit54e96451faa405952acbb12c3ff7e007b54d41b4 (patch)
tree97eba2239ae76632a9feb637d7cd88620e22394b
parent12c165a786cf52f7b72cc9b581860f01b448233a (diff)
Docker-based repro script by @infokiller
Ref #973
-rwxr-xr-xetc/examples/973-processes-performance-bug56
1 files changed, 56 insertions, 0 deletions
diff --git a/etc/examples/973-processes-performance-bug b/etc/examples/973-processes-performance-bug
new file mode 100755
index 00000000..b79e416d
--- /dev/null
+++ b/etc/examples/973-processes-performance-bug
@@ -0,0 +1,56 @@
+build_oci_img() {
+ # RUN apk add --no-cache bash git
+ docker build "$@" - <<'EOF'
+ FROM archlinux
+ RUN pacman -Sy > /dev/null
+ RUN pacman -S --noconfirm --needed coreutils curl gcc bc git > /dev/null
+ ENV CARGO_HOME=/usr/local
+ RUN curl -fsSL 'https://sh.rustup.rs' | sh -s -- -y --profile minimal
+ RUN /usr/local/bin/cargo install --version 0.11.3 git-delta && cp /usr/local/bin/delta /usr/local/bin/delta-0.11.3
+ RUN /usr/local/bin/cargo install --version 0.12.0 git-delta && cp /usr/local/bin/delta /usr/local/bin/delta-0.12.0
+ WORKDIR /repo
+EOF
+}
+
+build_oci_img
+docker run --rm -i "$(build_oci_img -q)" bash <<'EOF'
+benchmark-command() {
+ local num_runs="${1:-100}"
+ shift
+ local before
+ before=$(($(date +%s%N) / 1000000))
+ printf 'Running command "%s" %d times\n' "$*" "${num_runs}"
+ for _ in $(seq 1 "${num_runs}"); do
+ eval -- "$@" > /dev/null
+ done
+ local after
+ after=$(($(date +%s%N) / 1000000))
+ local per_run
+ per_run=$(bc < <(printf 'scale=2; %d/%d\n' $((after - before)) "${num_runs}"))
+ echo "${per_run} ms per run ($((after - before)) ms total)"
+}
+
+benchmark-delta-versions() {
+ for v in 0.11.3 0.12.0; do
+ echo "Benchmarking version: $v"
+ delta-${v} --version
+ benchmark-command 10 "git diff --no-index a b | delta-${v} >| delta-${v}-result"
+ done
+}
+
+main() {
+ echo aaa > a
+ echo aab > b
+ git diff --no-index a b | delta
+ benchmark-delta-versions
+ echo "Spinning up 5000 processes"
+ for i in {1..5000}; do
+ nohup sleep 30 & &> /dev/null
+ done
+ echo "Process counts:"
+ ps --no-headers -e -o fname | sort | uniq -c
+ benchmark-delta-versions
+}
+
+main
+EOF