[glib: 4/6] gspawn: Add sysprof trace support for spawning



commit 7cd67c935f2999da1428d9554695b3862ee82802
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Jun 25 22:27:10 2020 +0100

    gspawn: Add sysprof trace support for spawning
    
    Use this to replace the much-hated `g_debug()` which told people that
    `posix_spawn()` (the fast path) wasn’t being used for various reasons.
    
    If people want to make their process spawning faster now, they’ll have
    to use a profiling tool like sysprof to check their program’s
    performance. Shocking.
    
    I think I was wrong to put this `g_debug()` in there in the first place
    — it hasn’t served its purpose of making people speed up their spawn
    paths to use `posix_spawn()`, it’s only cluttered up logs and frustrated
    people.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 glib/gspawn.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/glib/gspawn.c b/glib/gspawn.c
index e5f1413ed..80ef669f8 100644
--- a/glib/gspawn.c
+++ b/glib/gspawn.c
@@ -54,6 +54,7 @@
 #include "gspawn.h"
 #include "gspawn-private.h"
 #include "gthread.h"
+#include "gtrace-private.h"
 #include "glib/gstdio.h"
 
 #include "genviron.h"
@@ -1760,7 +1761,10 @@ fork_exec_with_fds (gboolean              intermediate_child,
   if (!intermediate_child && working_directory == NULL && !close_descriptors &&
       !search_path_from_envp && child_setup == NULL)
     {
-      g_debug ("Launching with posix_spawn");
+      g_trace_mark (G_TRACE_CURRENT_TIME, 0,
+                    "GLib", "posix_spawn",
+                    "%s", argv[0]);
+
       status = do_posix_spawn (argv,
                                envp,
                                search_path,
@@ -1796,12 +1800,14 @@ fork_exec_with_fds (gboolean              intermediate_child,
     }
   else
     {
-      g_debug ("posix_spawn avoided %s%s%s%s%s",
-               !intermediate_child ? "" : "(automatic reaping requested) ",
-               working_directory == NULL ? "" : "(workdir specified) ",
-               !close_descriptors ? "" : "(fd close requested) ",
-               !search_path_from_envp ? "" : "(using envp for search path) ",
-               child_setup == NULL ? "" : "(child_setup specified) ");
+      g_trace_mark (G_TRACE_CURRENT_TIME, 0,
+                    "GLib", "fork",
+                    "posix_spawn avoided %s%s%s%s%s",
+                    !intermediate_child ? "" : "(automatic reaping requested) ",
+                    working_directory == NULL ? "" : "(workdir specified) ",
+                    !close_descriptors ? "" : "(fd close requested) ",
+                    !search_path_from_envp ? "" : "(using envp for search path) ",
+                    child_setup == NULL ? "" : "(child_setup specified) ");
     }
 #endif /* POSIX_SPAWN_AVAILABLE */
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]