[m-rev.] for post-commit review: cons_table reorganization

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Aug 24 02:01:39 AEST 2011


On Mon, 22 Aug 2011, Zoltan Somogyi wrote:

> The cons_table maps fully, partially and not-at-all module-qualified versions
> of cons_ids to the definitions of the corresponding data constructors.
>
> Up till now, this table has been implemented as a simple map from cons_ids
> to hlds_cons_defns. However, since cons_ids are nontrivial data structures,
> comparisons of the keys in this map is relatively expensive, and since each
> constructor's name is in the table several times, an access will perform
> many of these expensive comparisons.
>
> This diff makes the cons_table abstract, and changes its organization to a
> two-level map. The first level is a map from the constructor's name to an inner
> map, with the inner map mapping all cons_ids with a given name to their
> definitions.
>
> This can be expected to make lookups faster because lookups in the outer table
> need fewer comparisons (due to the absence of repetition) and these comparisons
> are faster (since a name is simpler than a cons_id). We still have to contend
> with repetitions and expensive comparisons in the inner table, but each inner
> table should be tiny.
>
> The overall effect on tools/speedtest -l is a speedup of about 2.5%.
>
> compiler/hlds_data.m:
> 	Make the change described above. Provide the operations on the
> 	cons_table that are needed by the rest of the compiler.
>
> 	Provide a predicate to look up not just a cons_id, but a cons_id
> 	in a particular type constructor. This factors out code that was
> 	present at several call sites, and allows those call sites to avoid
> 	repeatedly executing the same code on the same data, to wit, the
> 	several hlds_cons_defns returned for a given cons_id in a given
> 	type_ctor, which should ALL be identical.
>
> 	Insert all versions of a cons_id into the table at once, since
> 	this is significantly more efficient.
>
> compiler/add_type.m:
> compiler/equiv_type_hlds.m:
> compiler/hlds_module.m:
> compiler/intermod.m:
> compiler/passes_aux.m:
> compiler/post_typecheck.m:
> compiler/recompilation.usage.m:
> compiler/type_constraints.m:
> compiler/type_util.m:
> compiler/typecheck.m:
> compiler/typecheck_errors.m:
> 	Conform to the change above, taking advantage of the new facilities
> 	in hlds_data.m if possible.

That looks fine.

Julien.
--------------------------------------------------------------------------
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