-
Notifications
You must be signed in to change notification settings - Fork 7
Faster sir decoding #116
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
Faster sir decoding #116
Conversation
.section_data_by_name(id.name()) | ||
.unwrap_or(borrow::Cow::Borrowed(&[][..]))) | ||
.section_by_name(id.name()) | ||
.map(|sec| sec.data().expect("failed to decompress section")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What impact does compression have on performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. ykrustc is not emitting compressed elf sections. They are an ELF extension that is as far as I know only used for debug info in some cases.
@@ -64,7 +65,9 @@ lazy_static! { | |||
|
|||
impl Sir { | |||
pub fn read_file(file: &Path) -> Result<Sir, ()> { | |||
let ef = elf::File::open_path(file).unwrap(); | |||
// SAFETY: Not really, we hope that nobody changes the file underneath our feet. | |||
let data = unsafe { Mmap::map(&File::open(file).unwrap()).unwrap() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So mmap is faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two options when using object
. Either you load the whole file into a Vec<u8>
or you mmap the file. The former would also load the .text
and .data
sections, not just the .yksir_*
sections. Rustc also uses mmap for metadata loading. I have not benchmarked both approaches though.
Thanks for this. How much time does all of this shave off? |
In debug mode:
File size:
It is faster and produces smaller SIR. Bonus benchmarkIn release mode:
|
yktrace/src/sir.rs
Outdated
}; | ||
use ykpack::{self, bodyflags, Body, CguHash, Decoder, Local, Pack, Ty}; | ||
use memmap::Mmap; | ||
use object::{ObjectSection, Object}; // FIXME kill. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the FIXME about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I can't remember writing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is even weirder is that that line was created using the rust-analyzer import assist as far as I know.
I wish we could build just the SIR loading stuff with optimisations. We never need to trace that so we can optimise to our heart's content! |
Related: |
Would it be possible to build everything except for ykrt without tracing and then make ykrt call into the rest of the crates using |
(I'm debugging a buildbot problem, please ignore these bors try |
tryBuild failed: |
In theory yes, I guess we could force the optimisation flags in those crates (in Cargo.toml)? |
Please squash. |
d7695b9
to
529fdb9
Compare
Splat |
bors r+ |
116: Faster sir decoding r=vext01 a=bjorn3 Co-authored-by: bjorn3 <[email protected]>
Build failed: |
529fdb9
to
94224da
Compare
bors r+ |
116: Faster sir decoding r=vext01 a=bjorn3 Co-authored-by: bjorn3 <[email protected]>
Fixed rustfmt. This will need a ykrustc PR too because of the switch to bincode. |
Build failed: |
Do you just need a rebuild of ykrustc, or are there code changes? |
Just a rebuild against the new ykpack. Opened as softdevteam/ykrustc#128. Can you check that I made all changes necessary for cycle breaking? |
Wait, I need to fix a warning in this PR. |
94224da
to
99637e6
Compare
Can we wait for the upstream sync to go in before merging this? I'm just stuck with: |
The ykrustc PR already got a |
OK. I'll probably end up having to redo the sync. Rebasing pretty much never works well for them. bors r+ |
Build succeeded: |
No description provided.