-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Enable auto-compaction by default #3316
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
Draft
tenderlove
wants to merge
59
commits into
ruby:master
Choose a base branch
from
Shopify:read-barrier
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1a36004 to
3667936
Compare
17fdd81 to
cf875ba
Compare
b8fba34 to
b5601c6
Compare
f2c7c94 to
6612445
Compare
5287ffc to
12eadfc
Compare
535ddc9 to
b5f4938
Compare
f7ebd4c to
b40e2b8
Compare
The forwarding address was in the same slot as `klass` on RBasic. If there is a bug and something sees an RMoved object, it will think that the forwarding address is the class. We would like to detect those bugs asap, so this commit adds a dummy field in the same position as `klass` and sets the "class" to Qundef so hopefully we crash sooner
The call cache is a weak map and sometimes it can reference classes which will be collected. In the case it points to a collected class, update the class pointer to 0 (an uninitialized call cache)
Some objects that are protected by write barriers want to pin objects. One example is an identity hash. Identity hash is protected by a write barrier, but the keys to the hash cannot move as they are based on memory location. During incremental marking, if a reference is written to one of these objects, the reference is marked via the write barrier even though the mark function on the object would have marked *and* pinned it. To fix this, we will pin every reference that is marked via incremental marking because we cannot know if the object would have pinned its reference
Checking if T_NONE is marked is kind of an error, so lets just check the mark bits directly
If we don't call the marking function on the object, we need to assume the object must be pinned
This commit runs the compactor on every major GC
Compaction only updates references for "live" objects. But it depends on the "before_sweep" flag on a page to figure out which objects are live. If we're compacting, set the before_sweep flag so we don't try to update references on garbage objects
For example, objects that are in the finalizers table. They will be pinned but not marked. Since that is the case, the read barrier should ensure the type is T_MOVED before moving objects back.
We should only update objects on blocks that have live objects. If the objects are live, they won't have ASAN protection, so we should also remove the ASAN calls in order to catch bugs
Marked objects will not be "remarked" after the write barrier executes. Since we can't know whether or not the object would have pinned the reference that was written, we have to take a conservative approach and pin all references written via the write barrier
T_MOVED objects can get pushed on to the stack right before the final compact step. If this happens, the read barriers will get removed before anything has a chance to read from that address. This commit scans the stack when we finish compaction, looking for any moved addresses that happened to get pushed on the stack. If it finds any, it reverts those moves.
Mutating the object id map can cause the map to resize and that can cause a GC. The GC may read from the object id map *while* the map is being mutated, and that isn't safe. This commit disables the GC when mutating the object id map so that the GC won't see the map in an inconsistent state.
6ddfa61 to
b108e47
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is the same as #3547 except that it defaults auto compaction to enabled. In other words, it runs the entire test suite with GC compaction happening on every major GC.