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

Add -Z small-data-threshold #117465

Merged
merged 1 commit into from
Sep 12, 2024
Merged

Conversation

paulmenage
Copy link
Contributor

@paulmenage paulmenage commented Oct 31, 2023

This flag allows specifying the threshold size above which LLVM should not consider placing small objects in a .sdata or .sbss section.

Support is indicated in the target options via the
small-data-threshold-support target option, which can indicate either an
LLVM argument or an LLVM module flag. To avoid duplicate specifications
in a large number of targets, the default value for support is
DefaultForArch, which is translated to a concrete value according to the
target's architecture.

@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @b-naber (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 31, 2023
@paulmenage
Copy link
Contributor Author

paulmenage commented Oct 31, 2023

This is a more targeted version of what I was trying to achieve with #116555 (which would add -Z llvm-module-flag to enable the same goal on RISCV).

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@b-naber
Copy link
Contributor

b-naber commented Nov 17, 2023

Sorry for the late reply. I think this needs an MCP before it can be merged.

@bors
Copy link
Contributor

bors commented Nov 22, 2023

☔ The latest upstream changes (presumably #118178) made this pull request unmergeable. Please resolve the merge conflicts.

@b-naber
Copy link
Contributor

b-naber commented Dec 9, 2023

This could be merged now. Can you rebase?

@paulmenage
Copy link
Contributor Author

There's still some lack of clarity on the MCP zulip stream whether this is the right way to solve the problem, versus a target feature. I'll push the rebase but it's probably best to not merge it yet.

@paulmenage
Copy link
Contributor Author

OK, the conclusion on the zulip chat appeared to be that a target feature wasn't the right approach, so I think this is ready.

@apiraino
Copy link
Contributor

@b-naber can you r+? If I understand this patch is ripe for merging. thanks.

@compiler-errors
Copy link
Member

r? compiler-errors @bors r+

@bors
Copy link
Contributor

bors commented Feb 5, 2024

📌 Commit a618f74 has been approved by compiler-errors

It is now in the queue for this repository.

@rust-log-analyzer

This comment has been minimized.

@paulmenage paulmenage force-pushed the small-data-limit branch 2 times, most recently from c338170 to d470615 Compare September 10, 2024 18:16
@paulmenage
Copy link
Contributor Author

In the last update, I tweaked it to include a default based on the architecture, to avoid having to duplicate the support in many different target files.

// Set up the small-data optimization limit for architectures that use
// an LLVM module flag to control this.
(Some(threshold), SmallDataThresholdSupport::LlvmModuleFlag(flag)) => {
let flag = format!("{flag}\0");
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a CString for that, no need to manually add nulls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like let flag = CString::new(flag).unwrap()? Or should SmallDataThresholdSupport::LllvmModuleFlag contain a StaticCow<Cstr> rather than StaticCow<str>?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, changing type to StaticCow<Cstr> is probably no needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, tweaked to use let flag = SmallCStr::new(flag.as_ref());

//@ RISCV-NOT: .section
//@ RISCV: U:
//@ RISCV: .section .sbss
//@ RISV-NOT: .section
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. A bunch of copy-pasted typos, sorry. :-(

//@ RISV-NOT: .section
//@ RISCV: V:
//@ RISCV .section .sdata
//@ RISV-NOT: .section
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

//@ RISV-NOT: .section
//@ RISCV: W:
//@ RISCV: .section .sbss
//@ RISV-NOT: .section
Copy link
Contributor

Choose a reason for hiding this comment

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

...

//@ MIPS-NOT: .section
//@ MIPS: U:
//@ MIPS: .section .sbss
//@ RISV-NOT: .section
Copy link
Contributor

Choose a reason for hiding this comment

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

This and 2 next looks like should be MIPS-NOT?

//@ RISCV: .section .sbss
//@ RISV-NOT: .section
//@ RISCV: V:
//@ RISCV .section .sdata
Copy link
Contributor

Choose a reason for hiding this comment

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

:

//@ MIPS: .section .sbss
//@ RISV-NOT: .section
//@ MIPS: V:
//@ MIPS .section .sdata
Copy link
Contributor

Choose a reason for hiding this comment

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

:

This flag allows specifying the threshold size above which LLVM should
not consider placing small objects in a .sdata or .sbss section.

Support is indicated in the target options via the
small-data-threshold-support target option, which can indicate either an
LLVM argument or an LLVM module flag.  To avoid duplicate specifications
in a large number of targets, the default value for support is
DefaultForArch, which is translated to a concrete value according to the
target's architecture.
@paulmenage
Copy link
Contributor Author

I fixed the typos in the tests.

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 11, 2024

📌 Commit 3810386 has been approved by compiler-errors

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 11, 2024
@compiler-errors
Copy link
Member

Thanks @klensy for your thorough reviews as always

@workingjubilee
Copy link
Member

@bors rollup=iffy

@bors
Copy link
Contributor

bors commented Sep 12, 2024

⌛ Testing commit 3810386 with merge 1f51450...

@bors
Copy link
Contributor

bors commented Sep 12, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 1f51450 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 12, 2024
@bors bors merged commit 1f51450 into rust-lang:master Sep 12, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 12, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1f51450): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 1.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.5% [0.6%, 2.4%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [0.6%, 2.4%] 2

Cycles

Results (primary 6.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Binary size

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

Bootstrap: 756.297s -> 757.698s (0.19%)
Artifact size: 341.30 MiB -> 341.34 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.