This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[boehms-gc] support for cache hash tables (gt_ggc_cache_rtab)

Using weak pointers I've implemented support for gt_ggc_cache_rtab, so
that cached things do not survive collections just because they are
cached. Currently it's done by traversing gt_ggc_cache_rtab and
marking all the hash table slots as weak pointers on each collection.
If the objects pointed to by them are collected, they are
automatically set to NULL by the collector, which looks like
HTAB_EMPTY_ENTRY to others. By comparison, current collectors set them
to HTAB_DELETED_ENTRY, is this difference important, or just for

Regarding statistics, ggc-boehm does not record such automatic hash
table deletions by the collector, so htab.n_deleted data becomes
invalid. Currently I don't have any plan how to fix it. More
importantly, now the GTY if_marked argument is ignored, it is assumed
that it's always ggc_marked_p(). I Didn't investigate yet if there are
any other if_marked arguments used.

I lost my baseline GCC binaries, so hard performance data will be
posted later. But to make comparison with data posted on :

1: GCC with ggc-page
2: GCC with ggc-boehm, no weak pointers
3: GCC with ggc-boehm, weak pointers

  Peak GC allocated bytes: 1: 13915k 2: 52180k  3: 14996k
  GC execution time %: 1: 4% 2: 4% 3: 12%

  Peak GC allocated bytes: 1: 10049k 2: 35764k 3:13360k
  GC execution time %: 1: 6% 2: 5% 3: 14%

PR/8361 (C++)
  Peak GC allocated bytes: 1: 62510k 2: 289128k 3: 139748k
  GC execution time %: 1: 9% 2: 5% 3: 6%

PR/19614 (C++)
  Peak GC allocated bytes: 1: 139520k 2: 289140k 3: 167648k
  GC execution time %: 1: 17% 2: 15% 3: 17%

Overally things look very good here. This change alone brought
ggc-boehm memory usage down almost to the ggc-page level. I expect to
recover the rest with proper GTY flag "deletable" support. Then I will
attack CPU time.

Commited to the branch.


Index: gcc/ggc-boehm.c
--- gcc/ggc-boehm.c     (revision 115334)
+++ gcc/ggc-boehm.c     (working copy)
@@ -1,5 +1,6 @@
 #include "config.h"
 #include "system.h"
+#include "hashtab.h"
 #include "options.h"
 #include "params.h"
 #include "timevar.h"
@@ -11,6 +12,7 @@

 extern struct ht *ident_hash;

+static int ggc_htab_register_weak_ptr(void **slot, void *info);
 static size_t get_used_heap_size(void);
 static void register_gty_roots(void);
 static void gc_warning_filter(char * msg, GC_word arg);
@@ -47,9 +49,19 @@
  return result;

+ggc_htab_register_weak_ptr(void **slot, void *info ATTRIBUTE_UNUSED)
+  GC_general_register_disappearing_link (slot, *slot);
+  return 1;
 ggc_collect (void)
+  const struct ggc_cache_tab *const *ct;
+  const struct ggc_cache_tab *cti;
  /* Avoid frequent unnecessary work by skipping collection if the
     total allocations haven't expanded much since the last
     collection.  */
@@ -75,6 +87,18 @@
      stringpool_roots = ggc_register_stringpool_roots();

+  /* Register hash caches as weak pointers. Boehm's GC weak pointer facility
+     will clear any weak pointers to deleted objects.  After collection hash
+     table cleanup to shrink it should be performed. */
+  for (ct = gt_ggc_cache_rtab; *ct; ct++)
+    for (cti = *ct; cti->base != NULL; cti++)
+      if (*cti->base)
+       {
+         htab_traverse_noresize (*cti->base, ggc_htab_register_weak_ptr,
+                                 (void *)cti);
+       }
@@ -211,11 +235,10 @@
  const struct ggc_root_tab *const *rt;
  const struct ggc_root_tab *rti;

+  /* Register ordinary GC roots */
  for (rt = gt_ggc_rtab; *rt; rt++)
    for (rti = *rt; rti->base != NULL; rti++)
      GC_add_roots((char *)rti->base, (char *)rti->base + rti->stride);
-  /* TODO: it might be required to process gt_ggc_cache_rtab here */

 /* Register the stringpool entries as GGC roots.  In contrast to all other
Index: libcpp/include/symtab.h
--- libcpp/include/symtab.h     (revision 114687)
+++ libcpp/include/symtab.h     (working copy)
@@ -19,7 +19,9 @@

 #include "obstack.h"
+#ifndef GTY
 #define GTY(x) /* nothing */

 /* This is what each hash table entry points to.  It may be embedded
   deeply within another object.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]