[m-dev.] how many asserts/retractalls can *you* do per second?

Fergus Henderson fjh at cs.mu.oz.au
Tue Sep 9 22:27:07 AEST 1997


Thomas Charles CONWAY, you wrote:
> 
> You may have noticed that the sicstus version of the compiler was
> running a little slowly[1].

Ah.  No I hadn't noticed.  Apologies for the lack of testing.

> This clearly needs a bit of a rethink.

Yes, clearly.

> The reason seems to be that Fergus's
> recent change to io.nu.nl to make the io__state a "global" means
> that for each char that gets read, sicstus does an assert and a
> retract.  Same for each putback_char.

That's not correct.  It does not do an assert and retract for
each char read.  It only does a call to an asserted predicate.
It does do the retract and assert for each putback_char (which
for the lexer means roughly once for each token, I think).

Peter Schachte suggested using SICStus' mutable variables; that would
probably help putback_char, because update_mutable is probably a lot
cheaper than retractall+assert, but then read_char would still need a
call to an asserted predicate to get the name of the mutable variable,
plus an additional call to get the variable's value.

The reasons for making the io state global are
	- to avoid the need to passing it around, for
		- convenience, in the C interface
		- efficiency (if/when we change the code generator
		  to avoid actually passing it around)
	- to make it possible to implement `unsafe_perform_io'

Of these reasons, only the last one applies in the Prolog case,
the others only apply when compiling to C.  So perhaps we should
just put back basically the original code for io.nu.nl, 
and fudge unsafe_perform_io for Prolog.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list