Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(398)

Issue 71080043: code review 71080043: runtime: fix finalizer flakiness (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by rsc
Modified:
10 years, 2 months ago
Reviewers:
dvyukov
CC:
dvyukov, dave_cheney.net, golang-codereviews
Visibility:
Public.

Description

runtime: fix finalizer flakiness The flakiness appears to be just in tests, not in the actual code. Specifically, the many tests call runtime.GC once and expect that the finalizers will be running in the background when GC returns. Now that the sweep phase is concurrent with execution, however, the finalizers will not be run until sweep finishes, which might be quite a bit later. To force sweep to finish, implement runtime.GC by calling the actual collection twice. The second will complete the sweep from the first. This was reliably broken after a few runs before the CL and now passes tens of runs: while GOMAXPROCS=2 ./runtime.test -test.run=Finalizer -test.short \ -test.timeout=300s -test.cpu=$(perl -e 'print ("1,2,4," x 100) . "1"') do true; done Fixes issue 7328.

Patch Set 1 #

Patch Set 2 : diff -r d187b31342b5 https://code.google.com/p/go/ #

Patch Set 3 : diff -r d187b31342b5 https://code.google.com/p/go/ #

Patch Set 4 : diff -r 5414c904cc54 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -0 lines) Patch
M src/pkg/runtime/malloc.goc View 1 1 chunk +9 lines, -0 lines 0 comments Download

Messages

Total messages: 8
rsc
Hello dvyukov (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
10 years, 2 months ago (2014-03-04 06:29:24 UTC) #1
dave_cheney.net
I'm fine with this. I have little sympathy for bug reports that complain that calling ...
10 years, 2 months ago (2014-03-04 06:33:07 UTC) #2
dvyukov
I agree that users should not call GC manually in performance sensitive contexts. But what ...
10 years, 2 months ago (2014-03-04 06:45:45 UTC) #3
rsc
On Tue, Mar 4, 2014 at 1:45 AM, <dvyukov@google.com> wrote: > But what do you ...
10 years, 2 months ago (2014-03-04 06:51:24 UTC) #4
dvyukov
LGTM
10 years, 2 months ago (2014-03-04 06:56:39 UTC) #5
rsc
by the way, if you'd like to make this better, i would suggest looking into ...
10 years, 2 months ago (2014-03-04 14:46:17 UTC) #6
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=234b65f69439 *** runtime: fix finalizer flakiness The flakiness appears to be just ...
10 years, 2 months ago (2014-03-04 14:46:43 UTC) #7
dvyukov
10 years, 2 months ago (2014-03-14 06:59:24 UTC) #8
On Tue, Mar 4, 2014 at 6:46 PM, Russ Cox <rsc@golang.org> wrote:
> by the way, if you'd like to make this better, i would suggest looking into
> why it is that the bgsweep goroutine is not running quickly enough. the
> finalizer test in package runtime does a 4 second sleep after runtime.GC to
> wait for the finalizer to be run. it seems like bgsweep should be able to
> complete and then run finalizers in under 4 seconds. my guess is that there
> is a race and that on some invocations bgsweep does not get woken up. in
> fact i think i see a race between the park in bgsleep and the wakeup in the
> collector. but my attempted fix did not make any difference to the test
> failing.


okay, there are 3 races in that code
i will send fixes




> if you do
>
> for i in $(seq 1 100); do
> GOMAXPROCS=2 ./runtime.test -test.run=Finalizer \
>     -test.short -test.timeout=300s \
>    -test.cpu=$(perl -e 'print ("1,2,4," x 100) . "1"')
> done
>
> then it typically fails (at least on my laptop) about 10% of the time, with
> or without my "bgsweep race" fix. but with this CL, it's really fixed.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b