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

Superfluous heap expansion #16

Open
qtcwt opened this issue Mar 12, 2021 · 0 comments
Open

Superfluous heap expansion #16

qtcwt opened this issue Mar 12, 2021 · 0 comments

Comments

@qtcwt
Copy link
Member

qtcwt commented Mar 12, 2021

Ralloc expands the heap when superblock free list is empty. However, currently more than one thread may notice that the free list is empty and expand the heap simultaneously, causing superfluous expansion.

One workaround is to expand the heap by some size proportional to the number of threads, so that even superfluous expansion occurs, it won't get too many superblocks at once and there's no real harm. We applied this workaround on the copy in Montage.

The ultimate solution might be to introduce some helping mechanism while linking and publishing newly allocated superblocks while still ensuring no data race.
To realize this, we may want to add a mark bit in the next_free field of each descriptor and in curr_addr. When curr_addr is marked, threads noticing that the free list is empty will help link superblocks made available by the most recent yet unfinished expansion. Any helper realizing that a descriptor has marked next_free knows someone else has linked it (it may now already be in use) and thus moves forward to link the next. Once helpers iterate through all descriptors, they try to CAS the new head in and unmark curr_addr.

The issue of this solution is that, currently next_free is pptr, which stores offset from the object and is hard to steal a bit for marking. I'll come back and implement this in the future when I have more free cycles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant