Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

std: optimize dlsym! macro and add a test for it #146019

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

Open
joboet wants to merge 1 commit into rust-lang:master
base: master
Choose a base branch
Loading
from joboet:better-dlsym

Conversation

Copy link
Member

@joboet joboet commented Aug 29, 2025

The dlsym! macro always ensures that the name string is nul-terminated, so there is no need to perform the check at runtime. Also, acquire loads are generally faster than a load and a barrier, so use them. This is only false in the case where the symbol is missing, but that shouldn't matter too much.

Copy link
Collaborator

rustbot commented Aug 29, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 29, 2025
@joboet joboet changed the title (削除) std: optimize dlsym! macro and add a test for it (削除ここまで) (追記) std: optimize dlsym! macro and add a test for it (追記ここまで) Aug 29, 2025

This comment has been minimized.

Copy link
Contributor

Just curious...

@bors2 try @rust-timer queue

This comment has been minimized.

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 29, 2025
std: optimize `dlsym!` macro and add a test for it
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 29, 2025
Copy link

rust-bors bot commented Aug 30, 2025

☀️ Try build successful (CI)
Build commit: e2bfd7f (e2bfd7fb1f49deb317bdee4685858a4b7e85d848, parent: fe55364329579d361b1ab565728bc033a7dba07e)

This comment has been minimized.

Copy link
Collaborator

Finished benchmarking commit (e2bfd7f): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 3
Improvements ✅
(secondary)
-2.7% [-2.9%, -2.5%] 6
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 3

Max RSS (memory usage)

Results (primary -1.0%, secondary -1.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.0% [2.7%, 3.3%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-9.0% [-9.0%, -9.0%] 1
Improvements ✅
(secondary)
-1.9% [-1.9%, -1.9%] 1
All ❌✅ (primary) -1.0% [-9.0%, 3.3%] 3

Cycles

Results (primary 1.9%, secondary 2.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.9% [1.9%, 1.9%] 1
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.9% [1.9%, 1.9%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 467.034s -> 466.989s (-0.01%)
Artifact size: 388.52 MiB -> 388.52 MiB (-0.00%)

tgross35, Dushistov, and KisaragiEffective reacted with hooray emoji

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 30, 2025
Copy link
Contributor

@tgross35 tgross35 left a comment
edited by rustbot
Loading

Choose a reason for hiding this comment

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

Looks great, r=me with a squash

View changes since this review

* Ensure nul-termination of the symbol name at compile-time
* Use an acquire load instead of a relaxed load and acquire fence
* Properly use `unsafe` and add safety comments
* Add tests
Copy link
Member Author

joboet commented Sep 2, 2025

Copy link
Collaborator

bors commented Sep 2, 2025

📌 Commit d0a2761 has been approved by tgross35

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 2, 2025
bors added a commit that referenced this pull request Sep 3, 2025
std: optimize `dlsym!` macro and add a test for it
The `dlsym!` macro always ensures that the name string is nul-terminated, so there is no need to perform the check at runtime. Also, acquire loads are generally faster than a load and a barrier, so use them. This is only false in the case where the symbol is missing, but that shouldn't matter too much.
Copy link
Collaborator

bors commented Sep 3, 2025

⌛ Testing commit d0a2761 with merge 0b56db0...

Copy link
Collaborator

The job test-various failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:
---- sys::pal::unix::weak::tests::dlsym_existing stdout ----
thread 'sys::pal::unix::weak::tests::dlsym_existing' (515653) panicked at library/std/src/sys/pal/unix/weak/tests.rs:16:25:
called `Option::unwrap()` on a `None` value
stack backtrace:
 0: __rustc::rust_begin_unwind
 1: core::panicking::panic_fmt
 2: core::panicking::panic
 3: core::option::unwrap_failed
 4: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- sys::pal::unix::weak::tests::dlsym_existing stdout end ----
failures:
 sys::pal::unix::weak::tests::dlsym_existing
test result: FAILED. 542 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 3.54s

Copy link
Collaborator

bors commented Sep 3, 2025

💔 Test failed - checks-actions

@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 3, 2025
@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 3, 2025
Copy link
Contributor

tgross35 commented Sep 3, 2025

I wonder if it failed because of abs itself being a weak symbol so not getting pulled in if there is hardware support? Maybe something like printf would work better.

Copy link
Contributor

tgross35 commented Sep 3, 2025

@rustbot author (aggressively making sure my assigned PRs are triaged today)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@tgross35 tgross35 tgross35 approved these changes

Labels
O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /