Functional syntax (Was: RE: [mercury-users] Hi, and determini sm)

Thomas Conway conway at cs.mu.OZ.AU
Wed Feb 7 11:22:26 AEDT 2001


On Wed, Feb 07, 2001 at 10:41:43AM EST, Richard A. O'Keefe wrote:
> Of course, it all depends on how much data you have.  If packing your
> data tightly means that you stop thrashing VM, you'd better do it; if
> packing your data tightly means that you don't have many L2 cache
> misses, it's a good idea.
> 
> The only good use of C bit-fields I've seen recently in application-level
> code was a program that would have needed >1GB without, and can just
> squeeze into a 256MB machine with packing.

In the deep profiler that Zoltan and I have been working on, we need to
store very many profiling records (basically, we store the whole call
graph of the program, and record information about each call-site in
the call graph separately): for the compiler the number is over 80,000;
and we store more than 1 per node, because we also store aggregate
information.

A profiling record in general looks like:

:- type profiling_data
	--->	prof(
			calls	:: int,
			exits	:: int,
			fails	:: int,
			redos	:: int,
			exces	:: int,
			quanta	:: int
		).

However, for det procedures, 
	#calls == #exits + #exces
	#fails == 0
	#redos == 0

In the vast majority of these, the number of exceptions is 0, and in very
many the number of profiling quanta is 0. This leads to the following
representation:

:- type profiling_data
	--->	zdet(int)
			% #calls == #exits,
			% #fails == 0
			% #redos == 0
			% #exces == 0
			% #quanta == 0
	;	det(int, int)
			% #calls == #exits,
			% #fails == 0
			% #redos == 0
			% #exces == 0
			% #quanta != 0
	;	semi(int, int, int)
			% #calls == #exits + #fails,
			% #fails != 0
			% #redos == 0
			% #exces == 0
			% #quanta != 0
	;	all(int, int, int, int, int, int)
	.

We then use access functions to recover the all of the numbers
from this representation.

Because the number of functors is 4, in most environments we
can figure out which functor we have by examining the tag bits
on the pointer to the cell containing the values, so we get
a large reduction in the space used without paying too much
in performance.

-- 
  Thomas Conway )O+
 <conway at cs.mu.oz.au>       499 User error! Replace user, and press any key.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list