[m-rev.] diff: add performance note to state_var.m

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Feb 25 18:22:30 AEDT 2008


compiler/state_var.m:
	Add a note about performance.

Zoltan.

cvs diff: Diffing .
Index: state_var.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/state_var.m,v
retrieving revision 1.24
diff -u -b -r1.24 state_var.m
--- state_var.m	15 Feb 2008 02:26:58 -0000	1.24
+++ state_var.m	25 Feb 2008 05:33:50 -0000
@@ -783,10 +783,22 @@
     % that compares the numbers appended at the right hand ends of the
     % name strings.
     %
-    % NOTE state variable names are either "..._X" or "..._X_N" where X is
+    % NOTE State variable names are either "..._X" or "..._X_N" where X is
     % the name of the program variable used for the state variable and
     % N is a decimal number with no leading zeroes.
     %
+    % NOTE The code below looks a bit slow, since it extracts the numbers
+    % from the ends of variable names repeatedly. I (zs) tried to avoid
+    % this cost by making the read_only_dot, dot and colon maps in svar_infos
+    % map not just to a variable but a pair of a variable and a number,
+    % the number being the one we extract below. This even allowed us to avoid
+    % passing varsets in lots of places, since in many predicates varsets
+    % are needed only for looking up the variable names passed to
+    % compare_svar_names. However, I found that the result was an overall
+    % slowdown. Apparently, the overhead of recording the numbers, and of
+    % extracting the variables from the variable-number pairs in lookups,
+    % is higher than the overhead of compare_svar_names.
+    %
 :- pred compare_svar_names(comparison_result::out, string::in, string::in)
     is det.
 
cvs diff: Diffing notes
--------------------------------------------------------------------------
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