Two days ago, I wrote: > Find here attached a revised proposed patch. But I had missed the parallel 'sleep $am_cv_filesystem_timestamp_resolution'. Sorry, I have to withdraw that patch as well.
Now, with the big picture that I gained by replying to Karl's questions, here are two alternative, proposed patches. Both pass Automake's "make check". A) 0001-automake-Speed-up-_AM_FILESYSTEM_TIMESTAMP_RESOLUTIO.patch This patch reduces the sleep times on NetBSD 10 from 2 sec to under 0.5 sec. So it's a significant improvement for the first configure run on platforms without sub-second file system time resolution. This patch has no drawback for Mike Frysinger's "re-run with many smallish configure scripts with many cached vars" use-case, on platforms with sub-second file system resolution. The only drawback is that in Mike Frysinger's use-case, on platforms like NetBSD, each configure run will take 2 sec. minimum, instead of 1 sec minimum. This patch is conservative; IMO safe for a 1.17 release. B) 0001-automake-Save-up-to-2-seconds-of-configure-time.patch This patch reduces the sleep times on NetBSD 10 from 2 sec to nearly zero. So it's an even better improvement for the first configure run on platforms without sub-second file system time resolution. It also improves Mike Frysinger's "re-run with many smallish configure scripts with many cached vars" use-case, by elimininating all long sleeps in this case. The problem with this patch is that it reverts the change 5) in the history list <https://lists.gnu.org/archive/html/automake/2024-06/msg00054.html>; therefore it is quite possible that it reintroduces "make check" failures in Automake's test suite. I haven't seen such failures, but that doesn't mean they don't exist. This patch is risky. I think it's safe to commit only if followed by a 1-month testing period, where we can see if people report failures like they were reported in September 2010. Bruno
>From f1e6c0a5c7982a70d9d28798feb64c19cde20122 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Mon, 17 Jun 2024 00:13:21 +0200 Subject: [PATCH] automake: Speed up _AM_FILESYSTEM_TIMESTAMP_RESOLUTION execution. * m4/sanity.m4 (_AM_FILESYSTEM_TIMESTAMP_RESOLUTION): Don't test whether 1 sec works; instead just use 2 sec. --- m4/sanity.m4 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/m4/sanity.m4 b/m4/sanity.m4 index 68fbf36f7..a9eb8e740 100644 --- a/m4/sanity.m4 +++ b/m4/sanity.m4 @@ -32,8 +32,11 @@ AC_CACHE_CHECK([filesystem timestamp resolution], # Default to the worst case. am_cv_filesystem_timestamp_resolution=2 -# Only try to go finer than 1s if sleep can do it. -am_try_resolutions=1 +# Only try to go finer than 1 sec if sleep can do it. +# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work, +# - 1 sec is not much of a win compared to 2 sec, and +# - it takes 2 seconds to perform the test whether 1 sec works. +am_try_resolutions= if $am_cv_sleep_fractional_seconds; then # Even a millisecond often causes a bunch of false positives, # so just try a hundredth of a second. The time saved between .001 and -- 2.34.1
>From f8135b06c1a46228d974ec8edb1e928f8117d6e4 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 13 Jun 2024 13:47:49 +0200 Subject: [PATCH] automake: Save up to 2 seconds of configure time. * m4/sanity.m4 (AM_FILESYSTEM_TIMESTAMP_RESOLUTION): Renamed from _AM_FILESYSTEM_TIMESTAMP_RESOLUTION. Suggested by Karl Berry. (AM_SANITY_CHECK): Don't require _AM_FILESYSTEM_TIMESTAMP_RESOLUTION. Instead, execute it only when it is actually needed. In most cases outside Automake's test suite, it is not needed. Also, omit the parallel sleep. * configure.ac: Invoke AM_FILESYSTEM_TIMESTAMP_RESOLUTION. --- configure.ac | 1 + m4/sanity.m4 | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 3ff08e9f2..082d8bddb 100644 --- a/configure.ac +++ b/configure.ac @@ -190,6 +190,7 @@ AC_PROG_FGREP # The test suite needs to know the resolution of timestamps # supported by the filesystem hosting the build. The value # will be acceptable to 'sleep' on this system. +AM_FILESYSTEM_TIMESTAMP_RESOLUTION MTIME_RESOLUTION=$am_cv_filesystem_timestamp_resolution if test -z "$MTIME_RESOLUTION"; then AC_MSG_NOTICE(am_cv_filesystem_timestamp_resolution strangely not set; using 1) diff --git a/m4/sanity.m4 b/m4/sanity.m4 index 68fbf36f7..a8c6ff917 100644 --- a/m4/sanity.m4 +++ b/m4/sanity.m4 @@ -15,7 +15,7 @@ AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=true], [am_cv_sleep_fractional_seconds=false]) ])]) -# _AM_FILESYSTEM_TIMESTAMP_RESOLUTION +# AM_FILESYSTEM_TIMESTAMP_RESOLUTION # ----------------------------------- # Determine the filesystem's resolution for file modification # timestamps. The coarsest we know of is FAT, with a resolution @@ -25,7 +25,7 @@ AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=true], # possible to delay execution of a shell script for less than one # millisecond, due to process creation overhead and scheduling # granularity, so we don't check for anything finer than that. (See below.) -AC_DEFUN([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl +AC_DEFUN([AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl AC_REQUIRE([_AM_SLEEP_FRACTIONAL_SECONDS]) AC_CACHE_CHECK([filesystem timestamp resolution], am_cv_filesystem_timestamp_resolution, [dnl @@ -141,7 +141,7 @@ rm -f conftest.ts? # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], -[AC_REQUIRE([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION]) +[ # This check should not be cached, as it may vary across builds of # different projects. AC_MSG_CHECKING([whether build environment is sane]) @@ -179,6 +179,14 @@ for am_try in 1 2; do am_build_env_is_sane=yes break fi + # Determine am_cv_filesystem_timestamp_resolution. Do it only on the first + # loop round, since it is expensive. Do so without visible output, because + # we're already in a AC_MSG_CHECKING..AC_MSG_RESULT block. + if test $am_try = 1; then + exec 9>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null + AM_FILESYSTEM_TIMESTAMP_RESOLUTION + exec AS_MESSAGE_FD>&9 9>&- + fi # Just in case. sleep $am_cv_filesystem_timestamp_resolution am_has_slept=yes @@ -189,20 +197,4 @@ if test $am_build_env_is_sane = no; then AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi - -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -AS_IF([test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1],, [dnl - ( sleep $am_cv_filesystem_timestamp_resolution ) & - am_sleep_pid=$! -]) -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file ]) -- 2.34.1