Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: replace free list with direct bitmap allocation #12800

Closed
aclements opened this issue Sep 30, 2015 · 8 comments
Closed

runtime: replace free list with direct bitmap allocation #12800

aclements opened this issue Sep 30, 2015 · 8 comments

Comments

@aclements
Copy link
Member

All current releases of Go up to and including Go 1.5 use a mark-sweep garbage collector. As of Go 1.5, this works by alternating between a mostly-concurrent mark phase and a concurrent sweep phase. The mark phase finds all reachable objects and marks them, leaving all unreachable objects unmarked. The sweep phase walks through the entire heap, finds all unmarked objects, and adds them to free lists, which the allocator in turn uses to allocate new objects.

However, this sweep phase is, in a sense, redundant. It primarily transforms one representation of the free heap—the mark bits—into another representation of the free heap—the free lists. Not only does this take time, but the free list representation is unfriendly to modern CPUs since it is not very cacheable and accesses to it are hard to predict. Furthermore, the current mark representation is also cache-unfriendly, which adds even more to the cost of sweeping. All told, typical Go programs spend about 5% of their CPU time in the sweeper or in cache misses induced by the free list representation.

I propose eliminating the sweeper by foregoing the free list representation entirely and finding free objects directly using the mark bitmap. This can be done efficiently using a dense representation for mark bits separate from the current heap bitmap that enables fast scanning and clearing. This separate mark bitmap will also make it easy to maintain multiple mark bitmaps simultaneously, which is important for future GC improvements.

@aclements
Copy link
Member Author

I've uploaded the design doc CL at https://golang.org/cl/15210

@RLH

@gopherbot
Copy link

CL https://golang.org/cl/15210 mentions this issue.

gopherbot pushed a commit to golang/proposal that referenced this issue Oct 1, 2015
Updates golang/go#12800.

Change-Id: I7d040d8b96d401e2420d59c7d66bfe88a42bec08
Reviewed-on: https://go-review.googlesource.com/15210
Reviewed-by: Andrew Gerrand <adg@golang.org>
@aclements
Copy link
Member Author

The design doc can now be viewed in its native habitat at https://github.com/golang/proposal/blob/master/design/12800-sweep-free-alloc.md

@Dragomir-Ivanov
Copy link

@aclements Hi Austin, what is the plan for this? Is there will be proof of concept implementation. E.g. modify the GC, pass all the tests, etc. Thanks for all the work.

@RLH
Copy link
Contributor

RLH commented Oct 2, 2015

We have a partial prototype that still has bugs and is laden with
validation code. It is planned for 1.6, which means the CL will need to be
available before the end of the month. No numbers yet. It is going to
happen for 1.6.

On Fri, Oct 2, 2015 at 5:54 PM, Dragomir Ivanov notifications@github.com
wrote:

@aclements https://github.com/aclements Hi Austin, what is the plan for
this? Is there will be proof of concept implementation. E.g. modify the GC,
pass all the tests, etc. Thanks for all the work.


Reply to this email directly or view it on GitHub
#12800 (comment).

@gopherbot
Copy link

CL https://golang.org/cl/15560 mentions this issue.

@rsc rsc added this to the Proposal milestone Oct 24, 2015
@rsc rsc changed the title proposal: replace free list with direct bitmap allocation proposal: runtime: replace free list with direct bitmap allocation Oct 24, 2015
@rsc
Copy link
Contributor

rsc commented Oct 24, 2015

Accepting proposal. Certainly this is fine to implement and see how it works.

@rsc rsc changed the title proposal: runtime: replace free list with direct bitmap allocation runtime: replace free list with direct bitmap allocation Oct 24, 2015
@rsc rsc modified the milestones: Go1.6, Proposal Oct 24, 2015
@rsc rsc modified the milestones: Unplanned, Go1.6 Nov 5, 2015
@aclements
Copy link
Member Author

Bitmap allocation was merged in April with commit 56b5491 (plus a few follow-ups after the merge).

@golang golang locked and limited conversation to collaborators Jul 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants