]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: deinit: add a "quick-exit" option to bypass the deinit step
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Nov 2022 08:34:07 +0000 (09:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Nov 2022 08:37:09 +0000 (09:37 +0100)
Once in a while we spot a bug in the deinit code that is complex,
especially when it has to deal with incomplete initializations, and the
ability to bypass this step has regularly been raised. In addition for
fast-reloading setups it could theoretically save some time. Tests have
shown that very large configs can barely save ~100-150ms by skipping the
deinit step. However the ability not to crash if a bug is encountered can
occasionally help.

This patch adds an option to do exactly this. It's obviously not enabled
by default and the documentation discourages from using it, but this might
be useful in the future.

doc/configuration.txt
include/haproxy/global-t.h
src/cfgparse-global.c
src/haproxy.c

index cef8e7a8f6eb623f0085c424c0d31c847f2e83cc..7ce7ae5e01247b5d823e395d8cfaada37506f8dc 100644 (file)
@@ -3238,6 +3238,15 @@ anonkey <key>
   from the CLI command "set global-key". See also command line argument "-dC"
   in the management manual.
 
+quick-exit
+  This speeds up the old process exit upon reload by skipping the releasing of
+  memory objects and listeners, since all of these are reclaimed by the
+  operating system at the process' death. The gains are only marginal (in the
+  order of a few hundred milliseconds for huge configurations at most). The
+  main target usage in fact is when a bug is spotted in the deinit() code, as
+  this allows to bypass it. It is better not to use this unless instructed to
+  do so by developers.
+
 quiet
   Do not display any message during startup. It is equivalent to the command-
   line argument "-q".
index 1c7f45b3afa8d7ceef01dbb067ed035d1427b47e..0cdb361aeab6c7897facb2d8efa1b07417292c8d 100644 (file)
@@ -77,6 +77,7 @@
 #define GTUNE_IDLE_POOL_SHARED   (1<<20)
 #define GTUNE_DISABLE_H2_WEBSOCKET (1<<21)
 #define GTUNE_DISABLE_ACTIVE_CLOSE (1<<22)
+#define GTUNE_QUICK_EXIT         (1<<23)
 
 /* SSL server verify mode */
 enum {
index 62de1013a871687baac2b44389963ca8fc70bce0..6cc4afe13551a12394cf49953782686313bd5a3e 100644 (file)
@@ -1221,6 +1221,11 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                                env++;
                }
        }
+       else if (strcmp(args[0], "quick-exit") == 0) {
+               if (alertif_too_many_args(0, file, linenum, args, &err_code))
+                       goto out;
+               global.tune.options |= GTUNE_QUICK_EXIT;
+       }
        else if (strcmp(args[0], "strict-limits") == 0) { /* "no strict-limits" or "strict-limits" */
                if (alertif_too_many_args(0, file, linenum, args, &err_code))
                        goto out;
index 8064970622c75ed7109143812dddb49c6310d95c..9f5e75f53d8cf613e2b3ff0032725d37ee7f2bdc 100644 (file)
@@ -2637,6 +2637,10 @@ void deinit(void)
        struct cfg_postparser *pprs, *pprsb;
        int cur_fd;
 
+       /* the user may want to skip this phase */
+       if (global.tune.options & GTUNE_QUICK_EXIT)
+               return;
+
        /* At this point the listeners state is weird:
         *  - most listeners are still bound and referenced in their protocol
         *  - some might be zombies that are not in their proto anymore, but