[m-rev.] for review: remove a slow declarative debugger consistency check.
Ian MacLarty
maclarty at cs.mu.OZ.AU
Fri Apr 15 12:45:44 AEST 2005
On Fri, Apr 15, 2005 at 09:25:40AM +1000, Zoltan Somogyi wrote:
> On 14-Apr-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> > Remove the search space consistency check from decide_analyser_response/4.
>
> It would be better to leave the checks in, but execute them only if a flag
> is set, with the flag being clear by default.
>
Estimated hours taken: 1
Branches: main and 0.12
Only perform a consistency check on the search space if the
MR_DD_CHECK_SEARCH_SPACE C macro is defined. This check was slowing the
declarative debugger down considerably. The debugger/declarative/binary_search
test now takes about a second or two, instead of around 5-7 seconds previously
(these are estimates).
browser/declarative_analyser.m:
Call a wrapper predicate which only performs the check if
the C macro is defined.
browser/declarative_edt.m:
Add a wrapper predicate which only performs the check if the
C macro is defined.
Index: browser//declarative_analyser.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_analyser.m,v
retrieving revision 1.22
diff -u -r1.22 declarative_analyser.m
--- browser//declarative_analyser.m 11 Apr 2005 06:43:33 -0000 1.22
+++ browser//declarative_analyser.m 15 Apr 2005 01:57:14 -0000
@@ -465,10 +465,7 @@
is det <= mercury_edt(S, T).
decide_analyser_response(Store, Response, !Analyser) :-
- % Do a sanity check before the search. So we can determine afterwards
- % if the search corrupted the search space at all.
- % XXX this should be removed at some stage as it's relatively slow.
- check_search_space_consistency(Store, !.Analyser ^ search_space,
+ maybe_check_search_space_consistency(Store, !.Analyser ^ search_space,
"Start of decide_analyser_response"),
some [!SearchSpace] (
!:SearchSpace = !.Analyser ^ search_space,
@@ -494,10 +491,7 @@
!Analyser, Response)
)
),
- % Do a sanity check after the search to determine if the search
- % corrupted the search space at all.
- % XXX this should be removed at some stage as it's relatively slow.
- check_search_space_consistency(Store, !.Analyser ^ search_space,
+ maybe_check_search_space_consistency(Store, !.Analyser ^ search_space,
"End of decide_analyser_response").
:- pred handle_search_response(S::in, search_response::in,
Index: browser//declarative_edt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_edt.m,v
retrieving revision 1.6
diff -u -r1.6 declarative_edt.m
--- browser//declarative_edt.m 11 Apr 2005 06:43:33 -0000 1.6
+++ browser//declarative_edt.m 15 Apr 2005 02:33:30 -0000
@@ -487,12 +487,13 @@
:- pred revise_root(S::in, search_space(T)::in, search_space(T)::out)
is det <= mercury_edt(S, T).
- % Check the consistency of the search space and throw an exception
+ % Check the consistency of the search space if the
+ % MR_DD_CHECK_SEARCH_SPACE C macro is defined. Throw an exception
% if it's not consistent. Used for assertion checking during
% debugging.
%
-:- pred check_search_space_consistency(S::in, search_space(T)::in, string::in)
- is det <= mercury_edt(S, T).
+:- pred maybe_check_search_space_consistency(S::in, search_space(T)::in,
+ string::in) is det <= mercury_edt(S, T).
% Return the proc_label for the given suspect.
%
@@ -1127,6 +1128,18 @@
StopSuspects = []
).
+maybe_check_search_space_consistency(Store, SearchSpace, Context) :-
+ (
+ should_check_search_space_consistency
+ ->
+ check_search_space_consistency(Store, SearchSpace, Context)
+ ;
+ true
+ ).
+
+:- pred check_search_space_consistency(S::in, search_space(T)::in,
+ string::in) is det <= mercury_edt(S, T).
+
check_search_space_consistency(Store, SearchSpace, Context) :-
(
find_inconsistency_in_weights(Store, SearchSpace, Message)
@@ -1136,6 +1149,19 @@
;
true
).
+
+:- pred should_check_search_space_consistency is semidet.
+
+:- pragma foreign_proc("C",
+ should_check_search_space_consistency,
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
+ #ifdef MR_DD_CHECK_SEARCH_SPACE
+ SUCCESS_INDICATOR = MR_TRUE;
+ #else
+ SUCCESS_INDICATOR = MR_FALSE;
+ #endif
+").
Ian.
--------------------------------------------------------------------------
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