« Return to Thread: Ann: SWI-Prolog 5.6.54

Re: Ann: SWI-Prolog 5.6.54

by Jan Wielemaker :: Rate this Message:

Reply to Author | View in Thread

On Wednesday 16 April 2008 15:41, Tom Schrijvers wrote:

> > P.s. Tom, you can of course get the old behaviour using
> >
> > hash(Term, Hash) :-
> > (   integer(Term)
> > ->  Hash = Term
> > ;   hash_term(Term, Hash)
> > ).
> >
> > I think the new implementation is better as it guarantees proper
> > distribution when hashing integers that have some pattern.
>
> Good point. I should do some measurements to see which is faster on
> average. Hashing is a bottleneck in CHR. Exploiting the property that
> integers hash to themselves made a big difference.
>
> I expect the new hash_term/2 implementation is slower than before?

In some places it should be a bit faster, in others slower, but the
difference is very marginal:

SWI-Prolog 5.6.50
1 ?- time(forall(between(1, 10000000, X), hash_term(X, Hash))).
% 10,000,002 inferences, 1.89 CPU in 1.90 seconds (100% CPU, 5291006 Lips)

SWI-Prolog 5.6.54
1 ?- time(forall(between(1, 10000000, X), hash_term(X, Hash))).
% 10,000,002 inferences, 1.97 CPU in 1.97 seconds (100% CPU, 5076143 Lips)

This mostly measures the loop overhead :-)

> > P.s. I think hash_term/2 should be called term_hash/2.  Cf.
> > term_variables and argument order.  I'm a bit reluctant to change it
> > though.
>
> Yes, that does make more sense.

If nobody is going to object with good arguments I'll change that and
move hash_term/2 to library(backcomp).

        --- Jan


------------
For further info, please visit http://www.swi-prolog.org/

To unsubscribe, send a plaintext mail with "unsubscribe prolog <e-mail>"
in its body to majordomo@...

 « Return to Thread: Ann: SWI-Prolog 5.6.54

LightInTheBox - Buy quality products at wholesale price