[m-rev.] diff: avoid unnecessary rebuilding of parent modules

Peter Ross pro at missioncriticalit.com
Sun Nov 13 10:04:45 AEDT 2005


Hi,


===================================================================


Estimated hours taken: 2
Branches: main, release

There has been a performance bug that I introduced in 2002, where if a
child module module changes all of its parents are rebuilt, when the intention
was only to rebuild the parents who were in the same source file.

compiler/modules.m:
	Removed the dependency which causes the parent module to be rebuilt
	when ever any of it's children change, instead only rebuild the module
	if one of its nested sub-modules has changed.

Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.359
diff -u -r1.359 modules.m
--- compiler/modules.m	12 Nov 2005 10:16:49 -0000	1.359
+++ compiler/modules.m	12 Nov 2005 22:58:22 -0000
@@ -2964,7 +2964,7 @@
 write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :-
     Module = module_imports(SourceFileName, SourceFileModuleName,
         ModuleName, ParentDeps, IntDeps, ImplDeps, IndirectDeps,
-        _Children, InclDeps, _NestDeps, FactDeps0,
+        _Children, InclDeps, _NestedDeps, FactDeps0,
         ContainsForeignCode, ForeignImports0, _ContainsForeignExport,
         Items, _Error, _Timestamps, _HasMain, _Dir),
 
@@ -3094,15 +3094,6 @@
             ILDateFileName, " ",
             JavaDateFileName
         ] , !IO),
-        write_dependencies_list(ParentDeps, ".optdate", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".trans_opt_date", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".c_date", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".s_date", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".pic_s_date", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".dir/*.$O", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".rlo", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".il_date", DepStream, !IO),
-        write_dependencies_list(ParentDeps, ".java_date", DepStream, !IO),
         io__write_strings(DepStream, [" : ", SourceFileName], !IO),
         % If the module contains nested sub-modules then `.int0'
         % file must first be built.
@@ -3116,6 +3107,30 @@
         write_dependencies_list(LongDeps, ".int", DepStream, !IO),
         write_dependencies_list(ShortDeps, ".int2", DepStream, !IO),
 
+        NestedExts = [
+                ".optdate",
+                ".trans_opt_date",
+                ".c_date",
+                ".s_date",
+                ".pic_s_date",
+                ".dir/*.$O",
+                ".rlo",
+                ".il_date",
+                ".java_date"],
+
+            % If a module contains nested-submodules then we need to build
+            % the nested children before attempting to build the parent
+            % module
+        ( NestedDeps \= [] ->
+            Write = (pred(Ext::in, !.LIO::di, !:LIO::uo) is det :-
+                module_name_to_file_name(ModuleName, Ext, no, ExtName, !LIO),
+                io__write_strings(DepStream, ["\n\n", ExtName, " : "], !LIO),
+                write_dependencies_list(NestedDeps, Ext, DepStream, !LIO)
+            ),
+            list__foldl(Write, NestedExts, !IO),
+        ;
+            true
+        ),
         (
             FactDeps = [_ | _],
             io__write_strings(DepStream, [


-- 
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list