The Solaris 11.4 test run on GitHub is taking 4 hours, whereas it's only
1 hour (at most) on the other platforms.

In order to investigate this, I attached a time stamp to each output line:

  $make 2>&1 | gawk '{ print strftime("%H:%M:%S"), $0; fflush(); }' | tee log2
  $make check 2>&1 | gawk '{ print strftime("%H:%M:%S"), $0; fflush(); }' | tee 
log3

The result is that it's the new strengthened mcel tests that take so mch time:

  ...
  23:25:46 PASS: test-mbstowcs-5.sh
  23:25:46 PASS: test-mcel-1.sh
  01:32:30 PASS: test-mcel-2.sh   2 hours!
  01:32:31 PASS: test-mcel-3.sh
  01:37:29 PASS: test-mcel-4.sh   5 minutes
  03:40:09 PASS: test-mcel-5.sh   2 hours!
  03:40:09 PASS: test-memalign
  ...
  03:41:06 PASS: test-sinl
  03:41:08 PASS: test-sleep
  03:41:08 PASS: test-snan-1
  ...

I debugged it in a VM and found this stack trace:

main -> mcel_scant -> mcel_scan ->
rpl_mbrtoc32 -> locale_encoding_to_unicode -> get_converters ->
rpl_iconv_open -> iconv_open -> iconv_open_real -> iconv_open_private -> 
_icv_get_handle -> dlopen -> ...

Upon each rpl_mbrtoc32 invocation, the code is invoking iconv_open (even twice),
and that calls dlopen, which does lots of filesystem and mmap() calls.

The function 'get_converters' was meant to cache its result, but didn't.

This patch fixes it and brings the execution times down to ca. 4 seconds.


2024-05-25  Bruno Haible  <br...@clisp.org>

        uchar-c23: Speed up mbrtoc32 on Solaris 11.4.
        * lib/lc-charset-unicode.c (get_converters): Cache the return value.

diff --git a/lib/lc-charset-unicode.c b/lib/lc-charset-unicode.c
index f6529c1600..4558f9288e 100644
--- a/lib/lc-charset-unicode.c
+++ b/lib/lc-charset-unicode.c
@@ -107,6 +107,7 @@ get_converters (const char *encoding)
           return NULL;
         }
       strcpy (conv->encoding, encoding);
+      gl_tls_set (converters_key, conv);
     }
   else if (strcmp (conv->encoding, encoding) != 0)
     {




Reply via email to