]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix non-concurrent sweep
authorRuss Cox <rsc@golang.org>
Wed, 12 Feb 2014 20:54:21 +0000 (15:54 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 12 Feb 2014 20:54:21 +0000 (15:54 -0500)
State of the world:

CL 46430043 introduced a new concurrent sweep but is broken.

CL 62360043 made the new sweep non-concurrent
to try to fix the world while we understand what's wrong with
the concurrent version.

This CL fixes the non-concurrent form to run finalizers.
This CL is just a band-aid to get the build green again.

Dmitriy is working on understanding and then fixing what's
wrong with the concurrent sweep.

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/62370043

src/pkg/runtime/mgc0.c

index a6dc1d58ae8bfe2a3f74ca29e17b437564402a76..012e4dbcaacce5ea3aed9af7d6dc135ab777512a 100644 (file)
@@ -66,6 +66,7 @@ enum {
        CollectStats = 0,
        ScanStackByFrames = 1,
        IgnorePreciseGC = 0,
+       ConcurrentSweep = 0,
 
        // Four bits per word (see #defines below).
        wordsPerBitmapWord = sizeof(void*)*8/4,
@@ -2237,6 +2238,23 @@ runtime·gc(int32 force)
        runtime·semrelease(&runtime·worldsema);
        runtime·starttheworld();
        m->locks--;
+
+       // now that gc is done, kick off finalizer thread if needed
+       if(!ConcurrentSweep) {
+               if(finq != nil) {
+                       runtime·lock(&gclock);
+                       // kick off or wake up goroutine to run queued finalizers
+                       if(fing == nil)
+                               fing = runtime·newproc1(&runfinqv, nil, 0, 0, runtime·gc);
+                       else if(fingwait) {
+                               fingwait = 0;
+                               runtime·ready(fing);
+                       }
+                       runtime·unlock(&gclock);
+               }
+               // give the queued finalizers, if any, a chance to run
+               runtime·gosched();
+       }
 }
 
 static void
@@ -2384,7 +2402,7 @@ gc(struct gc_args *args)
        sweep.spanidx = 0;
 
        // Temporary disable concurrent sweep, because we see failures on builders.
-       if(false) {
+       if(ConcurrentSweep) {
                runtime·lock(&gclock);
                if(sweep.g == nil)
                        sweep.g = runtime·newproc1(&bgsweepv, nil, 0, 0, runtime·gc);