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

chore: use system linker in macOS #15407

Closed
wants to merge 1 commit into from

Conversation

BugenZhao
Copy link
Member

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

The performance of the system linker has improved a lot in Xcode 15 (shipped with macOS 14 and enabled by default). See https://news.ycombinator.com/item?id=36218330.

A simple benchmark on compiling cmd_all and linking the binary:

ld-new (default) 9.38s
lld             13.40s
ld-classic      14.45s

I believe it could outperforms further more under the release profile.

So let's switch to the system linker to improve the experience and reduce the number of dependencies.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@xxchan xxchan enabled auto-merge March 4, 2024 08:15
@xxchan xxchan added this pull request to the merge queue Mar 4, 2024
Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

LGTM. Still don't know why I ran into that weird issue.

@xxchan xxchan removed this pull request from the merge queue due to a manual request Mar 4, 2024
@xxchan
Copy link
Member

xxchan commented Mar 4, 2024

LGTM. Still don't know why I ran into that weird issue.

We might need to double-check this before merging

@BugenZhao
Copy link
Member Author

Still don't know why I ran into that weird issue.

I've reproduced the same issue. 😕 This appears to be a long-standing issue of linkme not correctly work under macOS if inter-crate lto is not enabled: dtolnay/linkme#61. cc @wangrunji0408 Do you have any ideas?

Some observations:

  • We also use linkme for system catalogs. It still works well. The difference is that all definitions of system catalogs live in the same crate (frontend).
  • Homebrew build of RisingWave has already switched to the system linker since risingwavelabs/homebrew-risingwave@73103d3. However, there's no such issue. I suppose it's because we enable lto for release build.
  • The LLVM linker does not have this issue either. Not sure if the problem only applies to Apple's linker.

@BugenZhao BugenZhao marked this pull request as draft March 5, 2024 05:42
@BugenZhao BugenZhao requested a review from wangrunji0408 March 8, 2024 05:56
@wangrunji0408
Copy link
Contributor

If linkme continues to make trouble, we can replace it by https://github.com/dtolnay/inventory. It relies on ctor and doesn't have too much link-time magics.

@BugenZhao
Copy link
Member Author

BugenZhao commented Mar 8, 2024

If linkme continues to make trouble, we can replace it by dtolnay/inventory. It relies on ctor and doesn't have too much link-time magics.

Wow, so much magic! I think either of them works for us. I was once curious why linkme uses a complete different approach instead of simply wrapping ctor (or why don't we simply do this). It turns out to be an intentional design.

@BugenZhao BugenZhao force-pushed the bz/use-system-linker-macos branch from 96443b2 to bca0844 Compare March 12, 2024 06:55
@BugenZhao BugenZhao changed the base branch from main to bz/inventory March 12, 2024 06:55
Copy link
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @BugenZhao and the rest of your teammates on Graphite Graphite

@BugenZhao
Copy link
Member Author

If linkme continues to make trouble, we can replace it by dtolnay/inventory. It relies on ctor and doesn't have too much link-time magics.

Wow, so much magic! I think either of them works for us. I was once curious why linkme uses a complete different approach instead of simply wrapping ctor (or why don't we simply do this). It turns out to be an intentional design.

#15631 (comment) 🥲

@BugenZhao BugenZhao closed this Mar 12, 2024
@xxchan xxchan mentioned this pull request Oct 8, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants