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

[perf] don't use temporary files for archive builder #104191

Closed
wants to merge 2 commits into from

Conversation

belovdv
Copy link
Contributor

@belovdv belovdv commented Nov 9, 2022

This is a draft - for perf testing only.

r? @petrochenkov

@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 Nov 9, 2022
@belovdv belovdv marked this pull request as draft November 9, 2022 11:53
@petrochenkov
Copy link
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 9, 2022
@bors
Copy link
Contributor

bors commented Nov 9, 2022

⌛ Trying commit eb0cba5437deeb68fc44c60b6df85fbfc219ad7e with merge 2a3475da1922519835b37aa7d28bfc574e55f09d...

@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 9, 2022
@bors
Copy link
Contributor

bors commented Nov 9, 2022

☀️ Try build successful - checks-actions
Build commit: 2a3475da1922519835b37aa7d28bfc574e55f09d (2a3475da1922519835b37aa7d28bfc574e55f09d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2a3475da1922519835b37aa7d28bfc574e55f09d): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

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

Instruction count

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

Max RSS (memory usage)

Results

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.8% [0.5%, 3.7%] 48
Regressions ❌
(secondary)
2.5% [0.6%, 5.2%] 84
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) 1.8% [-0.1%, 3.7%] 49

Cycles

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 9, 2022
@bjorn3
Copy link
Member

bjorn3 commented Nov 9, 2022

There doesn't seem to be much task clock or wall time change in either direction, but it shows a clear regression in max-rss. I think having a way to stream archive files directly to the disk while building them would work better. This is not something that LLVM supports though and it is non-trivial for every variant of the ar archive format due to the presence of the symbol table (and for the gnu variant a member name table for long names) that needs to be at the start of the file. For lld the symbol table is optional since recently as it was found to not provide a perf benefit for lld, but most other linkers still mandate it's presence.

@petrochenkov
Copy link
Contributor

@bjorn3

but it shows a clear regression in max-rss

I don't understand why it happens.
LLVM's NewArchiveMember::getFile reads this file back into memory or mmaps it if it's large enough.
In the second case all the pages will also be retreived because they need to be read.
Not sure where the memory economy comes from.

@@ -24,6 +24,8 @@ use rustc_session::Session;
pub struct LlvmArchiveBuilder<'a> {
sess: &'a Session,
additions: Vec<Addition>,

buffers: Vec<(String, Vec<u8>)>,
Copy link
Contributor

Choose a reason for hiding this comment

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

If this PR goes towards merging, then this is better added as a new variant to enum Addition instead of a separate vector.

@petrochenkov
Copy link
Contributor

r? @bjorn3

@rustbot rustbot assigned bjorn3 and unassigned petrochenkov Nov 10, 2022
@bjorn3
Copy link
Member

bjorn3 commented Nov 10, 2022

Not sure where the memory economy comes from.

Mmap only counts towards max-rss when being paged in afaik. In addition the os is free to page it out even when no swap memory exists as it can be loaded from the original file again. This last point is important as without we did likely hit an OOM condition a lot more on systems with little memory.

@klensy
Copy link
Contributor

klensy commented Nov 10, 2022

This was run on CI with SSD\NVMe drives (probably), maybe running it on HDD will show the diff.

@belovdv
Copy link
Contributor Author

belovdv commented Nov 13, 2022

Changes could be more noticeable after #104091, so I'll work on that first.
@rustbot author

@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 Nov 13, 2022
@bors
Copy link
Contributor

bors commented Dec 3, 2022

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

@Dylan-DPC
Copy link
Member

@belovdv any updates on this?

@belovdv
Copy link
Contributor Author

belovdv commented Feb 16, 2023

I couldn't find clear benefits from this change (please, correct me if it's wrong).

@belovdv belovdv closed this Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

8 participants