From 440ef03df8d8bba4432126f36168c1f7631c18dc Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 23 Mar 2026 19:22:08 +0100 Subject: Cross-platform process metrics support (#887) - **Cross-platform `GetProcessMetrics`**: Implement Linux (`/proc/{pid}/stat`, `/proc/{pid}/statm`, `/proc/{pid}/status`) and macOS (`proc_pidinfo(PROC_PIDTASKINFO)`) support for CPU times and memory metrics. Fix Windows to populate the `MemoryBytes` field (was always 0). All platforms now set `MemoryBytes = WorkingSetSize`. - **`ProcessMetricsTracker`**: Experimental utility class (`zenutil`) that periodically samples resource usage for a set of tracked child processes. Supports both a dedicated background thread and an ASIO steady_timer mode. Computes delta-based CPU usage percentage across samples, with batched sampling (8 processes per tick) to limit per-cycle overhead. - **`ProcessHandle` documentation**: Add Doxygen comments to all public methods describing platform-specific behavior. - **Cleanup**: Remove unused `ZEN_RUN_TESTS` macro (inlined at its single call site in `zenserver/main.cpp`), remove dead `#if 0` thread-shutdown workaround block. - **Minor fixes**: Use `HttpClientAccessToken` constructor in hordeclient instead of setting private members directly. Log ASIO version at startup and include it in the server settings list. --- src/zenserver/main.cpp | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'src/zenserver/main.cpp') diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index dff162b1c..00b7a67d7 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -249,7 +249,9 @@ test_main(int argc, char** argv) zen::MaximizeOpenFileCount(); - return ZEN_RUN_TESTS(argc, argv); + zen::testing::TestRunner Runner; + Runner.ApplyCommandLine(argc, argv); + return Runner.Run(); } #endif @@ -267,26 +269,6 @@ main(int argc, char* argv[]) using namespace zen; using namespace std::literals; - // note: doctest has locally (in thirdparty) been fixed to not cause shutdown - // crashes due to TLS destructors - // - // mimalloc on the other hand might still be causing issues, in which case - // we should work out either how to eliminate the mimalloc dependency or how - // to configure it in a way that doesn't cause shutdown issues - -#if 0 - auto _ = zen::MakeGuard([] { - // Allow some time for worker threads to unravel, in an effort - // to prevent shutdown races in TLS object destruction, mainly due to - // threads which we don't directly control (Windows thread pool) and - // therefore can't join. - // - // This isn't a great solution, but for now it seems to help reduce - // shutdown crashes observed in some situations. - WaitForThreads(1000); - }); -#endif - enum { kHub, -- cgit v1.2.3