[m-rev.] diff: speed up trail unwinding in .par.tr grades
Julien Fischer
juliensf at csse.unimelb.edu.au
Wed Sep 24 16:40:55 AEST 2008
Estimated hours taken: 1
Branches: main
Speed up trail unwinding and resets with trail segments in .par grades.
The total runtime for the G12 FD benchmarks is about 0.25% faster with this change.
Note that the speedup is not uniform across all benchmarks; it varies from no change
up to about a 4% improvement.
runtime/mercury_trail.c:
Cache the value of MR_TRAIL_BASE in a local variable where
possible, since in some grades the MR_TRAIL_BASE macro
makes a call to pthread_getspecific(). We do the same
in other grades too - it won't make any difference other
than to keep the code simple.
Julien.
Index: runtime/mercury_trail.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trail.c,v
retrieving revision 1.17
diff -u -r1.17 mercury_trail.c
--- runtime/mercury_trail.c 5 Sep 2008 11:19:33 -0000 1.17
+++ runtime/mercury_trail.c 24 Sep 2008 06:23:10 -0000
@@ -44,7 +44,11 @@
void
MR_untrail_to(MR_TrailEntry *old_trail_ptr, MR_untrail_reason reason)
{
- MR_TrailEntry *tr_ptr;
+ MR_TrailEntry *tr_ptr;
+
+#if defined(MR_TRAIL_SEGMENTS)
+ MR_TrailEntry *tr_base;
+#endif
/* Not needed, since MR_trail_ptr is never a real reg: */
/* MR_restore_transient_registers(); */
tr_ptr = MR_trail_ptr;
@@ -54,6 +58,7 @@
case MR_commit:
/* Just handle the function trail entries */
+ tr_base = MR_TRAIL_BASE;
while (tr_ptr != old_trail_ptr) {
tr_ptr--;
if (MR_get_trail_entry_kind(tr_ptr) == MR_func_entry) {
@@ -68,7 +73,7 @@
** (invoking function trail entires as we go) until we find it.
*/
#if defined(MR_TRAIL_SEGMENTS)
- if (tr_ptr == MR_TRAIL_BASE
+ if (tr_ptr == tr_base
&& tr_ptr != old_trail_ptr)
{
MR_MemoryZones *prev_zones;
@@ -109,6 +114,7 @@
case MR_exception:
case MR_retry:
/* Handle both function and value trail entries */
+ tr_base = MR_TRAIL_BASE;
while (tr_ptr != old_trail_ptr) {
tr_ptr--;
if (MR_get_trail_entry_kind(tr_ptr) == MR_func_entry) {
@@ -119,11 +125,12 @@
MR_get_trail_entry_value(tr_ptr);
}
#if defined(MR_TRAIL_SEGMENTS)
- if (tr_ptr == MR_TRAIL_BASE
+ if (tr_ptr == tr_base
&& tr_ptr != old_trail_ptr)
{
MR_pop_trail_segment();
tr_ptr = MR_trail_ptr;
+ tr_base = MR_TRAIL_BASE;
}
#endif
}
@@ -189,17 +196,19 @@
MR_reset_trail_zone(void) {
MR_TrailEntry *tr_ptr;
-
+ MR_TrailEntry *tr_base;
+
tr_ptr = MR_trail_ptr;
+ tr_base = MR_TRAIL_BASE;
- while (tr_ptr != MR_TRAIL_BASE) {
+ while (tr_ptr != tr_base) {
tr_ptr--;
if (MR_get_trail_entry_kind(tr_ptr) == MR_func_entry) {
(*MR_get_trail_entry_untrail_func(tr_ptr))(
MR_get_trail_entry_datum(tr_ptr), MR_gc);
}
}
- MR_trail_ptr = MR_TRAIL_BASE;
+ MR_trail_ptr = tr_base;
}
/*---------------------------------------------------------------------------*/
--------------------------------------------------------------------------
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