[m-rev.] for review: Use --trans-opt-deps-spec option.

Peter Wang novalazy at gmail.com
Wed Jan 25 16:36:35 AEDT 2023


Suggestions for the name of the spec file are welcome.

I've attached the module order when the spec file is used,
and the changes to the analysis results.

---

Use the recently added --trans-opt-deps-spec option to break cycles in
the trans-opt dependency graph for the standard library. This enables
more parallelism when making the .trans_opt files; it now takes about
half as long as before.

Ordering modules sensibly, so that .trans_opt files are created in a
logical order, also improves analysis results for many predicates and
functions. The only results which show a regression with this change are
for deprecated forwarding predicates/functions.

In future, we will probably be able to trim more dependencies to further
improve parallelism, without impacting analysis results.

configure.ac:
    Check that the bootstrap compiler supports --trans-opt-deps-spec.

library/mer_std.trans_opt_deps_spec:
    Add the spec file that adjusts dependencies in the trans-opt
    dependency graph.

library/INTER_FLAGS:
    Use the --trans-opt-deps-spec option when building with mmake.

scripts/prepare_install_dir.in:
tools/binary:
tools/bootcheck:
tools/unary:
    Copy mer_std.trans_opt_deps_spec when preparing a copy of the
    library directory.

diff --git a/configure.ac b/configure.ac
index d87fa963e..dadb806aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -574,7 +574,7 @@ EOF
         $BOOTSTRAP_MC \
             --verbose \
             $link_static_opt conftest \
-            --term-pass2-2022-12-28 \
+            --trans-opt-deps-spec dummy \
             --no-ssdb \
             </dev/null >&AS_MESSAGE_LOG_FD 2>&1 &&
         test "`./conftest 2>&1 | tr -d '\015'`" = "Hello, world" &&
diff --git a/library/INTER_FLAGS b/library/INTER_FLAGS
index 73d5b77d6..537c21514 100644
--- a/library/INTER_FLAGS
+++ b/library/INTER_FLAGS
@@ -1,4 +1,5 @@
 --transitive-intermodule-optimization
+--trans-opt-deps-spec mer_std.trans_opt_deps_spec
 --no-warn-smart-recompilation
 --enable-termination
 --analyse-exceptions
diff --git a/library/mer_std.trans_opt_deps_spec b/library/mer_std.trans_opt_deps_spec
new file mode 100644
index 000000000..45ff3ab64
--- /dev/null
+++ b/library/mer_std.trans_opt_deps_spec
@@ -0,0 +1,269 @@
+module_allow_deps(private_builtin, []).
+module_allow_deps(builtin, [private_builtin]).
+
+%--------------------------------------%
+
+module_disallow_deps(univ, [
+    list,
+    require,
+    string,
+    type_desc
+    ]).
+
+module_disallow_deps(exception, [
+    io,
+    list,
+    solutions,
+    stm_builtin,
+    store,
+    string
+    ]).
+
+module_disallow_deps(require, [
+    enum,
+    list,
+    string,
+    string.format,
+    string.parse_util,
+    type_desc
+    ]).
+
+module_disallow_deps(maybe, [
+    list                % only for type
+    ]).
+
+module_disallow_deps(list, [
+    pretty_printer,
+    set_tree234,
+    string,
+    term
+    ]).
+
+%--------------------------------------%
+
+module_disallow_deps(int, [
+    array,              % only for modes
+    pretty_printer
+    ]).
+module_disallow_deps(int8, [pretty_printer]).
+module_disallow_deps(int16, [pretty_printer]).
+module_disallow_deps(int32, [pretty_printer]).
+module_disallow_deps(int64, [pretty_printer]).
+
+module_disallow_deps(uint, [pretty_printer]).
+module_disallow_deps(uint8, [pretty_printer]).
+module_disallow_deps(uint16, [pretty_printer]).
+module_disallow_deps(uint32, [pretty_printer]).
+module_disallow_deps(uint64, [pretty_printer]).
+
+module_disallow_deps(char, [pretty_printer]).
+module_disallow_deps(float, [pretty_printer]).
+module_disallow_deps(one_or_more, [pretty_printer]).
+module_disallow_deps(version_array, [pretty_printer]).
+
+module_disallow_deps(array, [
+    pretty_printer,
+    string.format,
+    string.parse_util,
+    type_desc           % only for dynamic_cast_to_array
+    ]).
+
+%--------------------------------------%
+
+module_disallow_deps(rtti_implementation, [
+    bitmap,
+    deconstruct,
+    string.format,
+    string.parse_util,
+    term_io,            % only for term_io.quoted_string
+    type_desc
+    ]).
+
+module_disallow_deps(type_desc, []).
+
+%--------------------------------------%
+
+module_disallow_deps(string, [
+    assoc_list,         % only for the type
+    deconstruct,
+    pretty_printer,
+    string.format,
+    string.parse_util,
+    string.to_string
+    ]).
+module_disallow_deps(string.parse_util, [
+    deconstruct,
+    pretty_printer,
+    string.format,
+    string.to_string
+    ]).
+module_disallow_deps(string.parse_runtime, [
+    deconstruct,
+    pretty_printer,
+    string.format,
+    string.to_string
+    ]).
+module_disallow_deps(string.format, [
+    deconstruct,
+    pretty_printer,
+    string.to_string
+    ]).
+module_disallow_deps(string.to_string, []).
+
+%--------------------------------------%
+
+module_disallow_deps(tree234, [
+    io,                 % only for trace goals
+    pretty_printer,
+    term                % only for var type
+    ]).
+
+module_disallow_deps(map, [term]).
+module_disallow_deps(set, [term]).
+module_disallow_deps(set_ordlist, [term]).
+module_disallow_deps(set_tree234, [term]).
+
+module_disallow_deps(term, [
+    term_int,
+    term_subst,
+    term_unify,
+    term_vars
+    ]).
+
+module_disallow_deps(term_conversion, [bitmap]).
+
+%--------------------------------------%
+
+% These only import io for the io.state.
+module_disallow_deps(table_builtin, [io]).
+module_disallow_deps(time, [io]).
+
+module_disallow_deps(io.error_util, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.call_system,
+    io.environment,
+    io.file,
+    io.primitives_read,
+    io.primitives_write,
+    io.stream_db,
+    io.stream_ops,
+    io.text_read
+    ]).
+module_disallow_deps(io.file, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.call_system,
+    io.environment,
+    io.primitives_read,
+    io.primitives_write,
+    io.stream_db,
+    io.stream_ops,
+    io.text_read
+    ]).
+module_disallow_deps(io.environment, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.call_system,
+    io.file,
+    io.primitives_read,
+    io.primitives_write,
+    io.stream_db,
+    io.stream_ops,
+    io.text_read
+    ]).
+module_disallow_deps(io.call_system, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.environment,
+    io.file,
+    io.primitives_read,
+    io.primitives_write,
+    io.stream_db,
+    io.stream_ops,
+    io.text_read
+    ]).
+
+module_disallow_deps(io.stream_db, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.primitives_read,
+    io.primitives_write,
+    io.stream_ops,
+    io.text_read
+    ]).
+module_disallow_deps(io.stream_ops, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.primitives_read,
+    io.primitives_write,
+    io.stream_db,
+    io.text_read
+    ]).
+module_disallow_deps(io.primitives_read, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.primitives_write,
+    io.text_read
+    ]).
+module_disallow_deps(io.primitives_write, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io,
+    io.primitives_read,
+    io.text_read
+    ]).
+module_disallow_deps(io.text_read, [
+    benchmarking,
+    bitmap,
+    dir,
+    mercury_term_parser,
+    stream.string_writer,
+    io
+    ]).
+module_disallow_deps(io, [
+    benchmarking,           % just forwarding predicates
+    bitmap,                 % mostly forwarding predicates
+    dir,                    % only for dir.det_basename
+    mercury_term_parser,
+    stream.string_writer,
+    type_desc               % only for gc_init
+    ]).
+
+% term_io calls stream.string_writer.maybe_write_paren.
+% stream.string_writer calls term_io.quote_X.
+module_disallow_deps(term_io, [stream.string_writer]).
+module_disallow_deps(stream.string_writer, []).
+
+%--------------------------------------%
diff --git a/scripts/prepare_install_dir.in b/scripts/prepare_install_dir.in
index 8369a8863..fc5edeeec 100644
--- a/scripts/prepare_install_dir.in
+++ b/scripts/prepare_install_dir.in
@@ -80,6 +80,7 @@ cp library/Mmake* ${installdir}/library
 cp library/Mercury.* ${installdir}/library
 cp library/.mgnuc* ${installdir}/library
 cp library/*FLAGS* ${installdir}/library
+cp library/mer_std.trans_opt_deps_spec ${installdir}/library
 cp library/print_extra_inits ${installdir}/library
 cp library/library_strong_name.sn ${installdir}/library
 cp library/*.m ${installdir}/library
diff --git a/tools/binary b/tools/binary
index 4e58a3b81..b97c5bf5a 100755
--- a/tools/binary
+++ b/tools/binary
@@ -286,6 +286,7 @@ cp $root/library/Mmake* .
 cp $root/library/Mercury* .
 cp $root/library/*FLAGS* .
 cp $root/library/MODULES* .
+cp $root/library/mer_std.trans_opt_deps_spec .
 cp $root/library/.mgnuc* .
 cd $root/stage2
 mkdir mdbcomp
@@ -430,6 +431,7 @@ then
     cp $root/library/Mercury* .
     cp $root/library/*FLAGS* .
     cp $root/library/MODULES* .
+    cp $root/library/mer_std.trans_opt_deps_spec .
     cp $root/library/.mgnuc* .
 
     cd $root/stage3
diff --git a/tools/bootcheck b/tools/bootcheck
index 0eacff87e..bf8b9f8c2 100755
--- a/tools/bootcheck
+++ b/tools/bootcheck
@@ -809,6 +809,7 @@ then
         cp "${root}"/library/Mmake* "${root}"/library/Mercury.options .
         cp "${root}"/library/*_FLAGS.in .
         cp "${root}"/library/INTER_FLAGS* .
+        cp "${root}"/library/mer_std.trans_opt_deps_spec .
         cp "${root}"/library/.mgnu* .
         ${LN_S} "${root}"/library/${STD_LIB_NAME}.init .
         ${LN_S} "${root}"/library/RESERVED_MACRO_NAMES .
@@ -1480,6 +1481,7 @@ EOF
     cp "${root}"/library/Mmake* "${root}"/library/Mercury.options .
     cp "${root}"/library/*_FLAGS.in .
     cp "${root}"/library/INTER_FLAGS* .
+    cp "${root}"/library/mer_std.trans_opt_deps_spec .
     cp "${root}"/library/.mgnu* .
     ${LN_S} "${root}"/library/${STD_LIB_NAME}.init .
 
diff --git a/tools/unary b/tools/unary
index 4d25d770d..3f80c081a 100755
--- a/tools/unary
+++ b/tools/unary
@@ -253,6 +253,7 @@ cp $root/library/print_extra_inits .
 cp $root/library/Mmake* .
 cp $root/library/Mercury* .
 cp $root/library/*FLAGS* .
+cp $root/library/mer_std.trans_opt_deps_spec .
 cp $root/library/.mgnuc* .
 cd $root/stage2
 mkdir mdbcomp
@@ -371,6 +372,7 @@ then
     ln -s $root/library/*.init .
     cp $root/library/Mercury* .
     cp $root/library/*FLAGS* .
+    cp $root/library/mer_std.trans_opt_deps_spec .
     cp $root/library/.mgnuc* .
     cp $root/library/Mmake* .
     cd $root/stage3
-- 
2.39.0

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mer_std.order-trans-opt
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20230125/6963db0c/attachment-0001.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: results.txt.gz
Type: application/gzip
Size: 10829 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20230125/6963db0c/attachment-0001.gz>


More information about the reviews mailing list