[sgen] Track down promoted size also with parallel minors
authorVlad Brezae <brezaevlad@gmail.com>
Tue, 18 Apr 2017 16:45:26 +0000 (19:45 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 15 May 2017 09:52:51 +0000 (12:52 +0300)
mono/sgen/sgen-copy-object.h
mono/sgen/sgen-gc.h
mono/sgen/sgen-major-copy-object.h
mono/sgen/sgen-simple-nursery.c

index 925af17275dd67a1d2606d0c302b1ba3d7a4c38b..bb97e4a681689a2000318aeed0de938f8d8bfff6 100644 (file)
@@ -108,7 +108,7 @@ copy_object_no_checks_par (GCObject *obj, SgenGrayQueue *queue)
                 */
                gboolean has_references = SGEN_VTABLE_HAS_REFERENCES (vt);
                mword objsize = SGEN_ALIGN_UP (sgen_client_par_object_get_size (vt, obj));
-               destination = major_collector.alloc_object_par (vt, objsize, has_references);
+               destination = COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION (vt, obj, objsize, has_references);
 
                par_copy_object_no_checks ((char*)destination, vt, obj, objsize);
 
@@ -139,5 +139,6 @@ copy_object_no_checks_par (GCObject *obj, SgenGrayQueue *queue)
 #endif
 
 #undef COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION
+#undef COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION
 #undef collector_pin_object
 #undef COPY_OR_MARK_PARALLEL
index 27727a537b697e8bd8bebe08166d8ee320d7e439..e3fe2ed226789a0ae463ea897242c9614ad89e6f 100644 (file)
@@ -547,6 +547,7 @@ typedef struct {
        gboolean is_parallel;
 
        GCObject* (*alloc_for_promotion) (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references);
+       GCObject* (*alloc_for_promotion_par) (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references);
 
        SgenObjectOperations serial_ops;
        SgenObjectOperations serial_ops_with_concurrent_major;
index e04bf9e063cf1727207af8ae62bbb5892d563936..b110a75d847a65adba6d90a3443a6b1648a1c985 100644 (file)
@@ -19,5 +19,6 @@
 } while (0)
 
 #define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION sgen_minor_collector.alloc_for_promotion
+#define COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION sgen_minor_collector.alloc_for_promotion_par
 
 #include "sgen-copy-object.h"
index ee72408b76f273ace13978c6ea126cc1af7fe032..39d08abcf16027b60b884376a02acbc9a2517ea3 100644 (file)
@@ -28,6 +28,19 @@ alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean ha
        return major_collector.alloc_object (vtable, objsize, has_references);
 }
 
+static inline GCObject*
+alloc_for_promotion_par (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references)
+{
+       /*
+        * FIXME
+        * Note that the stat is not precise. total_promoted_size incrementing is not atomic and
+        * even in that case, the same object might be promoted simultaneously by different workers
+        * leading to one of the allocated major object to be discarded.
+        */
+       total_promoted_size += objsize;
+       return major_collector.alloc_object_par (vtable, objsize, has_references);
+}
+
 static SgenFragment*
 build_fragments_get_exclude_head (void)
 {
@@ -72,6 +85,7 @@ init_nursery (SgenFragmentAllocator *allocator, char *start, char *end)
 
 #define collector_pin_object(obj, queue) sgen_pin_object (obj, queue);
 #define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION alloc_for_promotion
+#define COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION alloc_for_promotion_par
 
 #define COPY_OR_MARK_PARALLEL
 #include "sgen-copy-object.h"
@@ -120,6 +134,7 @@ sgen_simple_nursery_init (SgenMinorCollector *collector, gboolean parallel)
        collector->is_parallel = parallel;
 
        collector->alloc_for_promotion = alloc_for_promotion;
+       collector->alloc_for_promotion_par = alloc_for_promotion_par;
 
        collector->prepare_to_space = prepare_to_space;
        collector->clear_fragments = clear_fragments;