Skip to content

testing: panic in AllocsPerRun during parallel test #70464

@rsc

Description

@rsc

I propose that testing.AllocsPerRun panic if called during a parallel test,
because it cannot give accurate results in that context. Tests that use
the result in that context will be flaky.

For example, flake #70327 was caused by a test that called t.Parallel
and then used AllocsPerRun. The other tests running in parallel
had allocations that were observed by the AllocsPerRun, resulting
in inconsistent results and a flaky failure.

I've implemented this change in CL 630137.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Accepted

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions