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

Conversation

gbaraldi
Copy link
Member

xchg is a very expensive instruction when working with memory, on x86 (intel 11th gen) it has an implied lock and a latency of 19. A false positive here just means a slight amount of extra work so don't do that.

@gbaraldi gbaraldi requested a review from vchuravy May 31, 2023 19:43
src/gc.c Outdated Show resolved Hide resolved
src/gc.c Outdated Show resolved Hide resolved
src/gc.c Outdated Show resolved Hide resolved
@vchuravy vchuravy added performance Must go faster GC Garbage collector labels Jun 1, 2023
@oscardssmith
Copy link
Member

does this make a noticeable difference in benchmarks?

@vchuravy
Copy link
Member

vchuravy commented Jun 1, 2023

@d-netto I think this is correct and I think @gbaraldi had a benchmark example where this saved a few couple of percent.

@gbaraldi
Copy link
Member Author

gbaraldi commented Jun 1, 2023

On a very simple benchmark just to illustrate. But this reproduces

PR
❯ ~/julia4/julia test.jl -t4 (base)
8.333745 seconds (1.36 G allocations: 40.596 GiB, 46.29% gc time, 10.57% compilation time)

Master
❯ ~/julia7/julia test.jl -t4 (base)
8.707281 seconds (1.36 G allocations: 40.596 GiB, 48.79% gc time, 10.14% compilation time)

src/gc.c Show resolved Hide resolved
Copy link
Member

@d-netto d-netto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems mergeable to me.

@oscardssmith oscardssmith merged commit 0a2d6fc into JuliaLang:master Jun 8, 2023
d-netto added a commit that referenced this pull request Jul 17, 2023
d-netto added a commit that referenced this pull request Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants