missed optimization on basic loops
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- compilers, performance
Hướng nghiên cứu
Reproduce fill_one_fold and fill_one_loop in the linked Compiler Explorer link, then compare generated setup, remainder-handling, and loop instructions at -Copt-level=3 and -Copt-level=z. The relevant entry points are the two Rust functions and their LLVM IR. Done means the ordinary loop receives comparable or better codegen without relying on the fold formulation.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Surprisingly, the fold variant below generates (slightly) better code
https://godbolt.org/z/78G5W3MWf
#[unsafe(no_mangle)]
pub fn fill_one_fold(a: &mut [u32]) {
a.iter_mut().fold((), |(), x| *x = 1);
}
#[unsafe(no_mangle)]
pub fn fill_one_loop(a: &mut [u32]) {
for e in a.iter_mut() {
*e = 1;
}
}
At opt level 3 the main loop is the same, so for raw performance it won't matter much
.LBB1_3:
movups xmmword ptr [rdi + 4*r8], xmm0
movups xmmword ptr [rdi + 4*r8 + 16], xmm0
add r8, 8
cmp rdx, r8
jne .LBB1_3
But the setup code and handling the remainder (that does not fit in a vector register is worse. The total size is 28 versus 24 instructions.
When using -Copt-level=z, the main loop is actually worse by one instruction
.LBB0_2:
mov dword ptr [rdi + 4*rax], 1
inc rax
cmp rsi, rax
jne .LBB0_2
versus
.LBB1_1:
cmp rsi, rax
je .LBB1_3
mov dword ptr [rdi + rax], 1
add rax, 4
jmp .LBB1_1
What is worrying really is that a fairly basic loop is not handled optimally by LLVM.
- Ngôn ngữ chính
- Rust
- Star
- 123k
- Fork
- 16.6k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 532
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/rust
-
strictly_dominates missing a `=`Đang mởC-bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
rust-lang/rust#166722 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-run-make C-bug T-bootstrap
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`Đang mởrelnotes relnotes-tracking-issue T-libs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/rust
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
tamatebako/tebako#1155 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
swc-project/swc-next-issues#1148 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
registrystack/registry-stack#2828 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit bug priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
SocketDev/socket-patch#2364 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày