-
Notifications
You must be signed in to change notification settings - Fork 77
MallocMS page accounting #689
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
Conversation
I have a minor fix for a concurrency bug I noticed. Should I make the PR instead? EDIT: My fix actually simplifies some of the PR as it removes the extra parameter from |
Sure. You could also commit to this PR if you would like to. |
Okay will do 👍 EDIT: Hmm @qinsoon I think the PR is from your personal mmtk-core fork so I don't know how I can push to it. |
Use a compare_exchange for accessing active page metadata instead of load followed by a store
@qinsoon It's an OOM error for JikesRVM as we've changed how the memory accounting works. We should just be able to bump the heap size and it should pass (theoretically). |
Right. I am doing that in mmtk/mmtk-jikesrvm#128. |
Ah right -- missed that PR. Thank you 👍 |
binding-refs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I identified some performance issue. If an object is too large (more than one page), it will need to set multiple metadata bits, and the current implementation is inefficient. See in-line comments for possible solutions.
src/policy/mallocspace/global.rs
Outdated
// It is important to go to the end of the object, which may span a page boundary | ||
while page < start + size { | ||
if compare_exchange_set_page_mark(page) { | ||
self.active_pages.fetch_add(1, Ordering::SeqCst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cmpxchg and the fetch_add happen as two separate operations. One possible optimisation is working out locally how many page marks are set in this loop, and do one single fetch_all(n)
after the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Now I am using a local variable to store the number of pages, and do one fetch_add
in the end. I also did the same for unset_page_mark
.
src/policy/mallocspace/global.rs
Outdated
|
||
let mut page = chunk_start; | ||
while page < chunk_start + BYTES_IN_CHUNK { | ||
self.unset_page_mark(page); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. You probably don't want to set one bit at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to unset_page_mark(start, size)
. It does something similar to the set_page_mark()
, and use bulk zero in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me now. I don't see more problems.
The JikesRVM binding keeps failing. I will look at that tomorrow. |
Yeah I'm not so sure of the |
iterating objects.
That seems to be the problem, though I don't know why bulk zero does not work. I have reverted that part of the code. |
After fixing the issue above, I am still seeing failures frequently. But I suspect it is the same problem as mmtk/mmtk-jikesrvm#108 (which is not reproducible on our dev machines). As this PR changes how we account memory for malloc mark sweep and we actually increase the min heap size for benchmarks, GCs are triggered more frequently and therefore we see failures more frequently. I changed the heap size we use for malloc mark sweep in JikesRVM to mitigate the issue. |
This PR updates to mmtk-core mmtk/mmtk-core#689. With the changes in mmtk-core, mark sweep does page accounting, will require a larger heap size to run some benchmarks.
This PR changes how our malloc mark sweep accounts for memory. We are currently accounting bytes used, which is wrong. This PR changes that to page-based accounting. This PR addresses the issue #649 for malloc mark sweep (further work is still needed for the issue for our malloc API).