- 1
Тестовый Оффтоп #4
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Тестовый Оффтоп #4
#1: https://govnokod.ru/26373 https://govnokod.xyz/_26373
#1: https://govnokod.ru/26611 https://govnokod.xyz/_26611
#1: https://govnokod.ru/26824 https://govnokod.xyz/_26824
#1: https://govnokod.ru/26850 https://govnokod.xyz/_26850
#2: https://govnokod.ru/27102 https://govnokod.xyz/_27102
#3: https://govnokod.ru/27523 https://govnokod.xyz/_27523
0
Бесконечный оффтоп имени Борманда #5
#1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
#2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
#3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
#4: https://govnokod.ru/26838 https://govnokod.xyz/_26838
0
Электрика / электроника #4
#1: https://govnokod.ru/25437 https://govnokod.xyz/_25437
#2: https://govnokod.ru/25820 https://govnokod.xyz/_25820
#3: https://govnokod.ru/26570 https://govnokod.xyz/_26570
+1
Питушня #19
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
#14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
#15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
#16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
#17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
#18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
+3
Афганистан заебал.
+6
Раскрытие покровов. Настя, облачные технологии и Настенька.
+1
fn main() {
println!("Hello World!");
}
rustc --version --verbose:
rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: powerpc-unknown-linux-gnu
release: 1.52.1
LLVM version: 12.0.0
Error output
rustc ./hello.rs
Illegal instruction (core dumped)
https://github.com/rust-lang/rust/issues/85238
Open: clienthax opened this issue on May 12 · 6 comments
+5
// And then I replaced the idiomatic Rust code for working with block like
for (dline, (sline0, sline1)) in dst.chunks_mut(dstride).zip(tmp.chunks(TMP_BUF_STRIDE).zip(tmp2.chunks(TMP_BUF_STRIDE))).take(h) {
for (pix, (&a, &b)) in dline.iter_mut().zip(sline0.iter().zip(sline1.iter())).take(w) {
*pix = ((u16::from(a) + u16::from(b) + 1) >> 1) as u8;
}
}
// with raw pointers:
unsafe {
let mut src1 = tmp.as_ptr();
let mut src2 = tmp2.as_ptr();
let mut dst = dst.as_mut_ptr();
for _ in 0..h {
for x in 0..w {
let a = *src1.add(x);
let b = *src2.add(x);
*dst.add(x) = ((u16::from(a) + u16::from(b) + 1) >> 1) as u8;
}
dst = dst.add(dstride);
src1 = src1.add(TMP_BUF_STRIDE);
src2 = src2.add(TMP_BUF_STRIDE);
}
}
What do you know, the total decoding time for the test clip I used shrank from 6.6 seconds to 4.9 seconds. That’s just three quarters of the original time!
And here is the problem. In theory if Rust compiler knew that the input satisfies certain parameters i.e. that there’s always enough data
to perform full block operation in this case, it would be able to optimise code as good as the one I wrote using pointers or even better.
But unfortunately there is no way to tell the compiler that input slices are large enough to perform the operation required amount of times.
Even if I added mathematically correct check in the beginning it would not eliminate most of the checks.
https://codecs.multimedia.cx/2021/05/missing-optimisation-opportunity-in-rust/
0
Автомобиль-русофоб
https://habr.com/ru/post/572984/
Я нашел статью про Насру (formerly Gologub).
+1
C 5.2s gcc test.c
C++ 1m 25s g++ test.cpp
Zig 10.1s zig build-exe test.zig
Nim 45s nim c test.nim
Rust Stopped after 30 minutes rustc test.rs
Swift Stopped after 30 minutes swiftc test.swift
D Segfault after 6 minutes dmd test.d
Rust and Swift took too long to compile 400k lines, so I tried smaller numbers:
# lines Rust Swift D
2k 3.4s 0.8s
4k 9.0s 1.0s
8k 30.8s 2.3s
20k 3m 52s 11.8s 4.7s
100k - 5m 57s segfault
https://vlang.io/compilation_speed