Whamcloud - gitweb
EX-4015 lipe: add make-prompt-tag hack
authorJohn L. Hammond <jhammond@whamcloud.com>
Mon, 21 Feb 2022 14:20:27 +0000 (08:20 -0600)
committerJohn L. Hammond <jhammond@whamcloud.com>
Thu, 10 Mar 2022 17:25:19 +0000 (17:25 +0000)
Hack guile (make-prompt-tag ...) to return a list instead of a
gensym. This reduces catch overhead in multi-threaded code and is what
guile does eventually (see guile commit 283ab48d3f). Add this along
with some comments to ls3_scm_init() and rename that function to
ls3_module_init().

Test-Parameters: trivial testlist=sanity-lipe-scan3 facet=mds1
Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I2ddd324b290ee4e985bba171681927b9434bbcc5
Reviewed-on: https://review.whamcloud.com/46571
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lipe/src/lipe_scan3/ls3_main.c

index 27f7762..fa0ab67 100644 (file)
@@ -1033,9 +1033,15 @@ static int ls3_scm_to_exit_status(SCM rc)
        return scm_is_true(rc) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-static void ls3_scm_init(void *unused)
+static void ls3_module_init(void *unused)
 {
-       /* Need scm_c_eval_string("#t") here to prevent.
+       /* Install some hacks and create the "lipe" (LS3_MODULE_NAME)
+        * module. This is called before any options are handled.
+        *
+        * We needed scm_c_eval_string("#t") early to prevent the
+        * following with multiple threads. Probably not needed
+        * anymore.
+        *
         * Backtrace:
         * In ice-9/boot-9.scm:
         *   157: 3 [catch #t #<catch-closure 2774e80> ...]
@@ -1052,6 +1058,14 @@ static void ls3_scm_init(void *unused)
         */
        scm_c_eval_string("#t");
 
+       /* In guile-2.0.9 (catch ...) has pretty high overhead when
+        * multi-threaded since it uses (make-prompt-tag "prompt")
+        * which returns (gensym "prompt) and (gensym ...) takes two
+        * global mutexes. In guile 283ab48d3f make-prompt-tag was
+        * changed to return (list "prompt") instead of calling
+        * gensym. We override make-prompt-tag to do the same. */
+       scm_c_eval_string("(set! make-prompt-tag (lambda* (#:optional (stem \"prompt\")) (list stem)))");
+
        ls3_scm_fid_vtable = scm_make_vtable(
                scm_from_utf8_string("uwuw"),
                scm_c_define_gsubr("%fid-printer", 2, 0, 0, &ls3_scm_fid_printer));
@@ -1065,6 +1079,8 @@ static void ls3_scm_init(void *unused)
 # include "ls3_main.x"
 #endif
 
+       /* Every symbol exported by the lipe module needs to be listed
+        * here. Unfortunately? */
        scm_c_export(
        "FNM_CASEFOLD",
        "fnmatch?",
@@ -1132,7 +1148,7 @@ static void ls3_main_scm(void *data, int argc, char *argv[])
        ls3_tid = syscall(SYS_gettid);
 
        /* Define our primitives before loading any files. */
-       scm_c_define_module(LS3_MODULE_NAME, &ls3_scm_init, NULL);
+       scm_c_define_module(LS3_MODULE_NAME, &ls3_module_init, NULL);
 
        while ((c = getopt_long(argc, argv, "hil:s:v", options, NULL)) != EOF) {
                switch (c) {