From b1ce1927022d374198441afafeb27199fc8a052a Mon Sep 17 00:00:00 2001 From: eunhhu Date: Thu, 24 Sep 2026 17:14:54 +0100 Subject: Establish native micro runtime checkpoint --- .../004-direct-document-path/peak-launcher.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 research/experiments/004-direct-document-path/peak-launcher.c (limited to 'research/experiments/004-direct-document-path/peak-launcher.c') diff --git a/research/experiments/004-direct-document-path/peak-launcher.c b/research/experiments/004-direct-document-path/peak-launcher.c new file mode 100644 index 0000000..e9f6c00 --- /dev/null +++ b/research/experiments/004-direct-document-path/peak-launcher.c @@ -0,0 +1,26 @@ +#define _GNU_SOURCE +/* Fork from a small native launcher so a Python orchestrator's pre-exec RSS + * cannot become the measured worker's high-water mark. */ +#include +#include +#include +#include + +int main(int argc, char **argv) { + if (argc < 2) return 2; + pid_t child = fork(); + if (child < 0) return 2; + if (!child) { + execvp(argv[1], argv + 1); + _exit(127); + } + struct rusage usage; + int status; + if (wait4(child, &status, 0, &usage) < 0 || !WIFEXITED(status) || + WEXITSTATUS(status)) return 1; + long user_ns = usage.ru_utime.tv_sec * 1000000000L + usage.ru_utime.tv_usec * 1000L; + long system_ns = usage.ru_stime.tv_sec * 1000000000L + usage.ru_stime.tv_usec * 1000L; + fprintf(stderr, "PURE_PEAK_RSS_KIB=%ld\nPURE_USER_NS=%ld\nPURE_SYSTEM_NS=%ld\n", + usage.ru_maxrss, user_ns, system_ns); + return 0; +} -- cgit v1.2.3