-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Inline fail! causes significant slowdown in write() #14485
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
Comments
perf non-inlined
perf inlined:
nm non-inlined:
nm inlined:
|
BTW, theoretically that |
In this particular program we always call For comparison: if buf.len() > dst.len() {
return Err(std::io::IoError { kind: std::io::OtherIoError, desc: "", detail: None });
}
if buf.len() > dst.len() {
return Err(std::io::standard_error(std::io::OtherIoError));
}
if buf.len() > dst.len() {
unsafe { std::intrinsics::abort(); }
}
if buf.len() > dst.len() {
unsafe { libc::exit(1); }
}
The numbers are somewhat stable. |
With the currently nightly:
Inlined:
|
See #17386 |
Nominating because |
Updated title to be more precise. |
Assigning P-low, not 1.0. (We should also investigate whether this benchmark still has the same performance problems, since there were some discussion that some of these paths have been improved.) |
cat -v is a real life application and it being over 100% slower when you use fail! has nothing to do with micro benchmarks. |
Where is the 100% slower? #14485 (comment) doesn't suggest this; also, it's been a while since that measurement and IIRC there have been even more improvements since then. |
It was 100% slower in the original post. If it is a micro benchmark now then it was a micro benchmark then. If anything, the "significant" part has been improved. |
Also, is the performance impact caused by instruction cache effects, poor register allocation of the inlined code, or something else? The |
The historical performance is not relevant, we only care about the performance now; it's wrong and disingenuous to use the 100+% slower number as 'evidence' for something, if it is no longer actually the case. |
I'm not using it as evidence for anything. The facts are very simple:
Trying to rewrite history by now calling it a micro benchmark doesn't make Rust's performance problems go away. Here are some updated numbers: Inlined: 1.793 As you can see, both versions have gotten even slower since the last time I posted some numbers. But the inlined version has gotten "more worse" than the non-inlined version. I'll post perf results shortly. |
Inlined:
Not inlined:
|
I think there was some misunderstanding during the meeting where this was discussed -- I agree with @markoh that the example code is representative of an application (part of the Rust coreutils implementation) and not a microbenchmark. That said, it looks like the gap between the two versions has shrunk considerably. |
@mahkoh fair enough, I updated the title again. The main thing I was trying to do was having something more specific than "significant slowdown", full stop, not to denigrate the bug report. (Mostly because when skimming titles of bug reports, I wanted something that would jog my memory as to what specific situation was being described.) |
This seems to have been resolved. With
and
@mahkoh can you confirm this? |
They both take the same amount of time now, but the non-inlined version has again gotten slower: 0m1.727s |
Closing in favour of #17386. It will always cause a performance hit in some scenarios if it's more than a function call. |
…rences, r=Veykril fix: resolve Self type references in delegate method assist This PR makes the delegate method assist resolve any `Self` type references in the parameters or return type. It also works across macros such as the `uint_impl!` macro used for `saturating_mul` in the issue example. Closes rust-lang#14485
Consider the following snippet:
Inlining
fail()
causes significant slowdown in the following programhttps://gist.github.com/anonymous/48ba255d89c2f9bf636c
Inlined:
Non-inlined:
Compiled with
-O
. The program is tested withtime ./cat -v /tmp/blabla.txt > /dev/null
where the text file are 100MB of random data.Note that
core::slice::MutableVector::copy_memory
has the formwhere assert! expands to something similar to the inlined fail!() version above. This function is used by some Writers.
cc @cmr
The text was updated successfully, but these errors were encountered: