[m-rev.] diff: do not apply delay-death to large procedures

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Jul 25 17:52:31 AEST 2011


compiler/liveness.m:
	Do not delay the death of variables in debug grades if the number
	of variables in the procedure exceeds a configurable threshold.
	Delaying the death of variables means that at later and later calls,
	there are more and more variables whose values need to be saved on the
	stack. This has several bad consequences in large procedures:
	
	- some data structures, such as the livevals instructions we generate
	  before calls, have size that is linear in both the number of calls
	  and the number of variables, and therefore they tend to be quadratic
	  overall in size;
	- computing these data structures will take time that is at least
	  quadratic, and maybe worse;
	- since we generate both more and bigger live sets, the stack slot
	  allocation pass will take time that seems to be at least qubic;
	- the algorithm for trying to compress the pseudo-typeinfo array
	  describing all the stack slots at all the call sites will definitely
	  take qubic time;
	- it will also generate HUGE arrays, leading to HUGE .c files
	  (almost one GIGABYTE for zm_enums.m);
	- these huge files will take a long time to write out, and to compile
	  and link.

	The impact of this change on debuggability should be small, since
	the first step in debugging such huge procedures do is almost
	certainly breaking them up into small, understandable pieces.

compiler/options.m:
	Add an option, --delay-death-max-vars=N, to control the cutoff in
	liveness.m. Set the default value to 1000. This affects only a few
	predicates in the compiler, such as the huge switches in options.m,
	and the many-page predicate in handle_options.m.

doc/user_guide.texi:
	Document the new option.

	Fix the formatting of the text for a nearby existing option.

library/term.m:
library/varset.m:
	Add utility functions now needed by liveness.m.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/extra
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/extra
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/doc
cvs diff: Diffing boehm_gc/libatomic_ops/src
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/armcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops/tests
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/m4
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.181
diff -u -b -r1.181 liveness.m
--- compiler/liveness.m	21 Jul 2011 06:58:25 -0000	1.181
+++ compiler/liveness.m	22 Jul 2011 07:10:46 -0000
@@ -206,6 +206,7 @@
 :- import_module assoc_list.
 :- import_module bool.
 :- import_module io.
+:- import_module int.
 :- import_module list.
 :- import_module map.
 :- import_module maybe.
@@ -319,7 +320,18 @@
         AllowDelayDeath = trace_level_allows_delay_death(TraceLevel),
         AllowDelayDeath = yes,
         globals.lookup_bool_option(Globals, delay_death, DelayDeath),
-        DelayDeath = yes
+        DelayDeath = yes,
+        globals.lookup_int_option(Globals, delay_death_max_vars,
+            DelayDeathMaxVars),
+        % Don't count the variables in the vartypes map if the varset
+        % shows that it cannot possibly contain too many variables.
+        (
+            varset.num_allocated(VarSet) =< DelayDeathMaxVars
+        ;
+            map.count(VarTypes) =< DelayDeathMaxVars
+        ),
+        pred_info_get_origin(PredInfo, Origin),
+        Origin \= origin_special_pred(_)
     ->
         delay_death_proc_body(Goal2, Goal3, VarSet, Liveness0),
         trace [io(!IO)] (
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.695
diff -u -b -r1.695 options.m
--- compiler/options.m	16 Jul 2011 12:04:10 -0000	1.695
+++ compiler/options.m	22 Jul 2011 07:06:53 -0000
@@ -244,6 +244,7 @@
             % library to be linked in with an executable compiled in a .debug
             % grade.
     ;       delay_death
+    ;       delay_death_max_vars
 
     ;       stack_trace_higher_order
     ;       force_disable_ssdebug
@@ -1189,6 +1190,7 @@
     suppress_trace                      -   string(""),
     force_disable_tracing               -   bool(no),
     delay_death                         -   bool(yes),
+    delay_death_max_vars                -   int(1000),
     stack_trace_higher_order            -   bool(no),
     force_disable_ssdebug               -   bool(no),
     generate_bytecode                   -   bool(no),
@@ -2054,6 +2056,7 @@
 long_option("suppress-trace",           suppress_trace).
 long_option("force-disable-tracing",    force_disable_tracing).
 long_option("delay-death",              delay_death).
+long_option("delay-death-max-vars",     delay_death_max_vars).
 long_option("stack-trace-higher-order", stack_trace_higher_order).
 long_option("force-disable-ssdebug",    force_disable_ssdebug).
 long_option("generate-bytecode",        generate_bytecode).
@@ -3797,6 +3800,9 @@
         "\tbeyond the point of their last use, in order to make them",
         "\taccessible from as many debugger events as possible.",
         "\tHowever, it will not do this if this option is given.",
+        "--delay-death-max-vars <N>",
+        "\tDelay the deaths of variables only when the number of variables",
+        "\tin the procedure is no more than N. The default value is 1000.",
         "--stack-trace-higher-order",
         "\tEnable stack traces through predicates and functions with",
         "\thigher-order arguments, even if stack tracing is not",
cvs diff: Diffing compiler/notes
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.632
diff -u -b -r1.632 user_guide.texi
--- doc/user_guide.texi	23 Jul 2011 08:02:51 -0000	1.632
+++ doc/user_guide.texi	25 Jul 2011 01:42:10 -0000
@@ -6992,6 +6992,11 @@
 accessible from as many debugger events as possible.
 However, it will not do this if this option is given.
 
+ at item --delay-death-max-vars @var{N}
+ at findex --delay-death-max-vars
+Delay the deaths of variables only when the number of variables
+in the procedure is no more than N. The default value is 1000.
+
 @item --stack-trace-higher-order
 @findex --stack-trace-higher-order
 Enable stack traces through predicates and functions with
@@ -7042,9 +7047,9 @@
 or in Mercury (with @samp{--convert-to-mercury}).
 
 @sp 1
- at item --max-error-line-width <n>
+ at item --max-error-line-width @var{N}
 @findex --max-error-line-width
-Set the maximum width of an error message line to <n> characters
+Set the maximum width of an error message line to @var{N} characters
 (unless a long single word forces the line over this limit).
 
 @sp 1
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_cairo
cvs diff: Diffing extras/graphics/mercury_cairo/samples
cvs diff: Diffing extras/graphics/mercury_cairo/samples/data
cvs diff: Diffing extras/graphics/mercury_cairo/tutorial
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/monte
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/term.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/term.m,v
retrieving revision 1.135
diff -u -b -r1.135 term.m
--- library/term.m	25 May 2011 02:02:52 -0000	1.135
+++ library/term.m	9 Jul 2011 15:51:06 -0000
@@ -391,7 +391,7 @@
 :- pred context_file(context::in, string::out) is det.
 
     % Used to initialize the term context when reading in
-    % (or otherwise constructing) a 
+    % (or otherwise constructing) a term.
     %
 :- func context_init = context.
 :- pred context_init(context::out) is det.
@@ -453,6 +453,8 @@
     %
 :- func var_supply_max_var(var_supply(T)) = var(T).
 
+:- func var_supply_num_allocated(var_supply(T)) = int.
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -1133,6 +1135,8 @@
 
 var_supply_max_var(var_supply(V)) = var(V).
 
+var_supply_num_allocated(var_supply(V)) = V.
+
 %-----------------------------------------------------------------------------%
 
 relabel_variable(functor(Const, Terms0, Cont), OldVar, NewVar,
Index: library/varset.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/varset.m,v
retrieving revision 1.90
diff -u -b -r1.90 varset.m
--- library/varset.m	25 May 2011 02:02:52 -0000	1.90
+++ library/varset.m	9 Jul 2011 15:50:05 -0000
@@ -268,6 +268,8 @@
     %
 :- func varset.max_var(varset(T)) = var(T).
 
+:- func varset.num_allocated(varset(T)) = int.
+
 %-----------------------------------------------------------------------------%
 
 :- implementation.
@@ -696,13 +698,13 @@
 
 varset.max_var(varset(VarSupply, _, _)) = term.var_supply_max_var(VarSupply).
 
-%-----------------------------------------------------------------------------%
-%:- end_module varset.
+varset.num_allocated(varset(VarSupply, _, _)) =
+    term.var_supply_num_allocated(VarSupply).
+
 %-----------------------------------------------------------------------------%
 % Ralph Becket <rwab1 at cl.cam.ac.uk> 30/04/99
 %   Function forms added.
 
-
 varset.delete_var(!.VS, V) = !:VS :-
     varset.delete_var(V, !VS).
 
@@ -750,3 +752,7 @@
 
 varset.coerce(!.VS) = !:VS :-
     varset.coerce(!VS).
+
+%-----------------------------------------------------------------------------%
+%:- end_module varset.
+%-----------------------------------------------------------------------------%
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/appengine
cvs diff: Diffing samples/appengine/war
cvs diff: Diffing samples/appengine/war/WEB-INF
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/concurrency
cvs diff: Diffing samples/concurrency/dining_philosophers
cvs diff: Diffing samples/concurrency/midimon
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/java_interface
cvs diff: Diffing samples/java_interface/java_calls_mercury
cvs diff: Diffing samples/java_interface/mercury_calls_java
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/stm
cvs diff: Diffing tests/stm/orig
cvs diff: Diffing tests/stm/orig/stm-compiler
cvs diff: Diffing tests/stm/orig/stm-compiler/test1
cvs diff: Diffing tests/stm/orig/stm-compiler/test10
cvs diff: Diffing tests/stm/orig/stm-compiler/test2
cvs diff: Diffing tests/stm/orig/stm-compiler/test3
cvs diff: Diffing tests/stm/orig/stm-compiler/test4
cvs diff: Diffing tests/stm/orig/stm-compiler/test5
cvs diff: Diffing tests/stm/orig/stm-compiler/test6
cvs diff: Diffing tests/stm/orig/stm-compiler/test7
cvs diff: Diffing tests/stm/orig/stm-compiler/test8
cvs diff: Diffing tests/stm/orig/stm-compiler/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/stmqueue
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test10
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test11
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test9
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list