From 785d1bf1daeb59715ba904bb35f81b5261eb7ad4 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Tue, 27 Oct 2026 14:29:58 -0400 Subject: [PATCH] perf(proot): enable syscall patching by default --- docs/development/proroot-analysis.md | 22 ++++++++++++++-------- tools/proot/fastpath/svc-patch.h | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/development/proroot-analysis.md b/docs/development/proroot-analysis.md index 81be73a112..a63e40ad33 100644 --- a/docs/development/proroot-analysis.md +++ b/docs/development/proroot-analysis.md @@ -134,10 +134,11 @@ netlink and SysV shm (`netif.c` and `sysv.c` already cover these); and the long- ## First implementation and Thor validation (2026-10-27) -`tools/proot/fastpath/svc-patch.h`, included by `fastpath.c`, implements an opt-in first -slice of item 1. Set `PROOT_FP_PATCH_SVC=1` in a fresh process using the replacement -`libblfastpath.so`. The ordinary fast-path configuration and tracer-key check must also -succeed. It is disabled by default, skips processes that already have multiple threads, +`tools/proot/fastpath/svc-patch.h`, included by `fastpath.c`, implements the first +slice of item 1. It runs automatically in fresh processes using the replacement +`libblfastpath.so` when the ordinary fast-path configuration and tracer-key check +succeed. Set `PROOT_FP_PATCH_SVC=0` to disable it for troubleshooting or comparisons; +`PROOT_FP_PATCH_SVC=1` also explicitly enables it. It skips processes that already have multiple threads, and declines SVE/SME hardware because the relay preserves the base ARM64 register state. The scanner visits executable segments of the loaded `libc.so.6` and @@ -180,6 +181,11 @@ NZCV, FPCR/FPSR, four simultaneous threads, the multi-thread patching guard, and Null arguments and unsupported flags fall back to PRoot. The instruction decoder and exact ±128 MiB branch limits also have a host regression test. +Default-policy validation on the Thor confirmed that an unset `PROOT_FP_PATCH_SVC` +and explicit `1` both patched 14 sites; explicit `0` left all 415 libc and 56 linker +syscall sites unchanged. The register/thread/fork check also passed with the +environment flag unset. + Five alternating pairs of `bench/svc-workload.c` runs compared the same replacement library with patching off/on, with fast-path stats enabled in both. The workload gets `fstatat` and `__open64_nocancel` directly from libc, bypassing the preload's @@ -234,7 +240,7 @@ the start and completed with `No Error`. Existing installed games were retained. The repeat off/on pair used the exact same replacement library, SHA-256 `ab605c021aee271cd49fa1cb337d7ff0c762dbac198b711e9818639c0cd4b17d`. The first off run used the earlier adjacent-only build, with patching disabled. -Only the opt-in environment flag changed for the final pair. Times below come +Only the patching environment flag changed for the final pair. Times below come from Steam's one-second-resolution `content_log.txt`; total starts at Reconfiguring and ends at scheduler completion, excluding session startup: @@ -281,7 +287,7 @@ The installed PRoot pack emitted no profiling start/counter records despite the queued profiling setting; the profiler report had `hasCounters: false`. That is a measurement gap, not evidence of zero remaining traps. -Before enabling this by default: validate signal/cancellation/unwind behavior, +Further validation includes signal/cancellation/unwind behavior, additional glibc builds and workloads, startup cost and Steam/CEF tree RSS; obtain matching patch-0018 tracer measurements; and resolve the existing SD socket mismatch. Additional syscall families, Android-blocked syscall emulation and build-id caching @@ -305,7 +311,7 @@ Run `svc-probe` inside the app's guest environment, not from `adb shell`. `svc-check` embeds the fast path and requires its normal enabled tracer environment. For `svc-workload`, pass a prepared directory containing `file` and a `link` symlink to it; add any second argument to enable timing. Use the documented library override -workflow in [proot-performance](proot-performance.md) for a fresh session, adding -`PROOT_FP_PATCH_SVC=1` through `droiddeckctl env set` before starting it. +workflow in [proot-performance](proot-performance.md) for a fresh session. No extra +environment setting is needed; use `PROOT_FP_PATCH_SVC=0` for the unpatched comparison. `svc-storage` takes a new, unused directory name; it creates and removes its own test files and directory. It writes 64 MiB plus 16 MiB of file extensions per run. diff --git a/tools/proot/fastpath/svc-patch.h b/tools/proot/fastpath/svc-patch.h index f247f18d22..fde1c25119 100644 --- a/tools/proot/fastpath/svc-patch.h +++ b/tools/proot/fastpath/svc-patch.h @@ -207,7 +207,7 @@ static void svc_stats(void) { __attribute__((constructor)) static void svc_patch_init(void) { const char *enabled = getenv("PROOT_FP_PATCH_SVC"); - if (!enabled || strcmp(enabled, "1") || !fp_ready()) return; + if ((enabled && strcmp(enabled, "1")) || !fp_ready()) return; if (getauxval(AT_HWCAP) & HWCAP_SVE) return; #ifdef HWCAP2_SME if (getauxval(AT_HWCAP2) & HWCAP2_SME) return;