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

Don't use exchange in the hot path of the GC #50021

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ STATIC_INLINE void gc_queue_big_marked(jl_ptls_t ptls, bigval_t *hdr,
FORCE_INLINE int gc_try_setmark_tag(jl_taggedvalue_t *o, uint8_t mark_mode) JL_NOTSAFEPOINT
{
assert(gc_marked(mark_mode));
uintptr_t tag = o->header;
uintptr_t tag = jl_atomic_load_relaxed((_Atomic(uintptr_t)*)&o->header);
uintptr_t curr = tag;
if (gc_marked(tag))
return 0;
if (mark_reset_age) {
Expand All @@ -818,9 +819,9 @@ FORCE_INLINE int gc_try_setmark_tag(jl_taggedvalue_t *o, uint8_t mark_mode) JL_N
tag = tag | mark_mode;
assert((tag & 0x3) == mark_mode);
}
tag = jl_atomic_exchange_relaxed((_Atomic(uintptr_t)*)&o->header, tag);
verify_val(jl_valueof(o));
return !gc_marked(tag);
jl_atomic_store_relaxed((_Atomic(uintptr_t)*)&o->header, tag); //xchg here was slower than
verify_val(jl_valueof(o)); //potentially redoing work because of a stale tag.
return !gc_marked(curr);
gbaraldi marked this conversation as resolved.
Show resolved Hide resolved
}

// This function should be called exactly once during marking for each big
Expand Down