[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: 1735933314704534.png (29 KB, 680x357)
29 KB
29 KB PNG
And some retards still believe the compiler will optimize everything for you.
>>
>>106960353
ok but span is safer
>>
How does span work under the hood?
Is it like range in Python, where it creates a list that you then iterate over?
>>
>>106960353
Because you construct the span every loop. Retard
>>
>>106960353
Did you turn compiler optimizations on?
>>
>>106960882
Why can't our friend the clever compiler optimize it out?
>>
>>106960882
no?
>>
>>106960353
>meme "problems"
the only thing more retarded than sepples are those
>>
>>106960353
Rust doesn't have this problem.
running 3 tests
test tests::bench_fast ... bench: 4,499.43 ns/iter (+/- 95.62)
test tests::bench_idiomatic ... bench: 4,482.95 ns/iter (+/- 46.71)
test tests::bench_slow ... bench: 4,501.73 ns/iter (+/- 10.81)
>>
>>106960911
compiler devs and sepples committee talk big talk but can't walk the walk as usual
>brooo our compiler is super smart giga AI powered advanced algorithms and can optimize everything
>muh premature optimization is... LE ROOT OF ALL EVIL, o algo
>Muh sepples zero cost abstractions n'shiiieet
>>
>>106961306
Stop speaking like a nigger.
>>
>>106960353
>spans suck
almost like most shitty C++ features and their implementations are malicious compliance.
>>
>>106961312
ay yo man, i ain't a real nigga like yo pops, i's just be talkin like one cuz dem racis-ass crackas on 4chan start hootin' and hollerin' when i do. don't mind me cuh, i's be white as snow, y'gnomesayin? iss all coo, mane.
>>
>>106961303
based and idiomatic pilled. how will sepples sissies cope with this SAFE AND BEAUTIFUL implementation?
>>
>>106961306
>o algo
wtf does this even mean?
>>
>>106961360
O almighty god of ALGOrithms, O Algo!
>>106961303
>short and simple code that gives the exact same result compiling to a different assembly
Muh llvm is sooooo advanced o algo
>>
>>106961377
>>short and simple code that gives the exact same result compiling to a different assembly
Considering the speed is equal, this does not matter. Previous versions of Rust(eg 1.65) compiled it to the exact same machine code, but somewhere along the way they changed how this kind of code gets optimized and now iterators get inlined differently than ranges. There is still no measurable difference in performance.
>>
>>106961401
It does matter because the code in the first window creates longer and probably larger assembly code. If they could shrink down the assembly without affecting performance, why not do that?
>>
>>106961360
or something in beanspeak o algo
>>
>>106961423
>If they could shrink down the assembly without affecting performance, why not do that?
Because compiler only knows limited set of optimizations it can do in reasonable time, and these optimizations have to be universal enough to work on wide range of different platforms and architectures. These snippets of code generate IR distinct enough to trigger different kinds of optimizations which result in slightly different machine code.
If you want to learn more, you can use godbolt optimization pipeline analysis and look at it step by step too see what exactly happened, but I personally do not care enough to go through all of this.
>>
yet another "forgot to turn on optimizations" thread
but yeah it's annoying that C++ is basically unusable with -O0
>>
>>106960353
I don't get it. What causes this? The possibility of arr/cnt changing mid-loop? But the loop did eat breakfast...
>>
File: zero-cost.png (281 KB, 900x966)
281 KB
281 KB PNG
>>106961303
>>
>>106961559
>twitter e-celeb
Buy an ad and I might consider reading what you have to say.
>>
>>106961559
>gnu c/c++ versions
GNU coreutils are (almost) 100% C. Sepplesfags just won't shy away from cultural appropriation.
>>
>>106961559
do people who post this realize how low IQ they are?
You can easily write something in some higher level langauge like javascript and shit all over some cnile diarhea purely because your algorithm actually uses a proper hashmap. All this shows is that gnu coreutils took over decades of effort to highly optimize specific cases that a relatively new project hasn't yet.
>>
>>106960911
Because it might have side effects, which would then modify the program behavior
>>
File: rust-breaking-linux.png (199 KB, 802x842)
199 KB
199 KB PNG
>>106961572
>>106961577
>>
>>106961579
Why can't our friend the clever compiler figure this out?
>>
>>106961577
>You can easily write something in some higher level langauge like javascript and shit all over some cnile diarhea purely because your algorithm actually uses a proper hashmap
What makes you think the C versions use bad algorithms?
>>
>>106960353
You're doing it wrong.

Span is used to eliminate the unsafe aspect of such crusty C-style code. Use it to wrap the arrays directly back at the caller, then pass and use that span in functions safely. Simple as.
>>
>>106961604
I didn't say that? are you those retards who fall for the
>How would you feel if you didn't have breakfast?
shit? low IQ nigger. learn how to read.
>>
>>106961604
What makes you reply to a Rust troon spouting nonsense, with even more nonsense? Only reason I can think of is that you're another Rust troon (or samefagging) and trying to create a pretext for more Rustroon rhetoric to be spouted.
>>
File: rust-security.jpg (181 KB, 1793x1179)
181 KB
181 KB JPG
lol
>>
File: 1665577052561946.png (28 KB, 120x190)
28 KB
28 KB PNG
>>106961587
Ok, so what are you even trying to say by posting some random article?
If you are suggesting that the code I posted does not in fact sums the array, then you gotta argue it in better way than post an unrelated article about some unrelated project having unrelated problems.
>>
>>106961616
it isn't nonsense
after the gzdoom drama, I found out about
https://github.com/Helion-Engine/Helion
which shits all over all the cnile engines and it's written in C#.

language implementation isn't that important for performance in most cases.
>>
Reminder to ignore deranged Rust rhetoric and simply post Rust facts (>>106961629 >>106961587 >>106961559) instead.
>>
>>106961616
Meds. Now.
>>
>>106961613
What was the point of your post then?
>>
>>106961629
Yet another cnile forced to cope with fake graphs. It's like they don't even do basic fact checking and just fall for literal twitter troll in a desperate attempt to save their face lmao.

https://x.com/kai_fall/status/1966158913478566093
https://desuarchive.org/g/search/image/lpefOq3EscbItb7-JhCzyw/
>>
>>106961587
>>106961559
lol. imagine trying to clone existing, documented, open source software and failing this hard. now imagine if they had to actually invent it from scratch
>>
>>106961559
>luncuck
>>
>>106961821
>imagine trying to clone existing, documented, open source software and failing this hard
Because project like wayland, pulseaudio, systemd, bash and even linux itself never had compatibility problems with their predecessors, right?
>>
>>106961899
>project like wayland, pulseaudio, systemd, bash and even linux itself
which reference implementations were they trying (and miserably failing) to clone?
>>
>>106961552
the span version compiles to comparison to end pointer
int *end = arr + cnt;
while (arr != end) {
s += *arr;
arr += 1;
}

seriously doubt this is 60% slower. OP probably just forgot to turn on optimizations so the span methods were not inlined
>>
>>106961925
Wayland => xord, pulseaudio => OSS, systemd => init+many more, bash => Bourne Shell, linux => unix
Over the years, all of them suffered numerous incompatibilities with the projects/systems they tried to replace
>>
File: loops.png (87 KB, 998x701)
87 KB
87 KB PNG
>>106960353
kek
so it is not just in js - other languages has this too.
in js every loop perform slightly differently.
for example negative loops are faster than positive ones.
>>
>>106961971
>xord
*xorg
>>
>>106961971
the level of cope in this post is mindblowing. thanks for demonstrating why your community will never be taken seriously
>>
>>106961997
>thanks for demonstrating why your community will never be taken seriously
Only retarded normalfags do not take it seriously. Entire internet runs on Linux.
>>
>>106962012
ok, this is obviously a bot with a 200 token context window
>>
>>106961982
I wonder if the negative loop is so fast because it crashes on first iteration due to failed bound check
>>
>>106961982
Isn't reverse looping faster in all languages? Something to do with not having to check against the length or something? Also --i is better than i-- I think but that's probably optimized out.
>>
>>106961982
>200 iterations per second
whoa
>>
>>106962043
Shouldn't the condition be evaluated before the first iteration?
>>
>>106961958
Test it yourself and you'll see.
>>
Why does none of you ever look at godbolt.
>>
>>106962091
actually tried it and the end-pointer and span version is 60% faster, not slower
>>
>>106962498
that's -Og. on -O3 all are the same
>>
>>106960447
The tranny complex. Has to have safe sex because of dilation, now wants to force everyone else to do it too.
>>
File: tippingCoffeefunny.png (578 KB, 759x844)
578 KB
578 KB PNG
>>106960353
speaking of compiling; on Gnu/Linux. I'm working on an experiment to try to compile a huge 30k line program on a cellphone. The program compiles just fine and works as expected on a desktop. It will probabbly compile on a cellphone running linux, and I'm curious about this as a stress test for the phone. Phone has 4 Gig of ram and 512 ssd. Any ideas or inputs would be appreciated.

>Please wait a while before making a post
why?
>>
>>106962231
GCC generates slightly different code.
>>
>>106960353
i have literally never heard about this or seen it used.
>>
>>106960910
>>106961532
Man, people really just want to avoid this huh?
>>
>>106964820
Yeah I tried that code in godbolt it was essentially the same with O2 and O3.
>>
>>106960353
I have no idea what span is or does, sorry.
>>
C++ = proven and tested tech for decades
Rust = tranny shit
>>
File: benchmark.png (36 KB, 1271x891)
36 KB
36 KB PNG
Do it properly (by not creating and destroying a fucking object in every iteration of the loop) and you will see that it's as fast as the C-style arrays in an optimized build.

C-style arrays win in unoptimized builds though.

https://quick-bench.com/q/QhGzLYaQJ9SL-BZpmdMSKWP1IZI
>>
>>106961982
As a developer, my time is more valuable than your CPU cycles.
>>
>>106961629
This is actually a graph of the average IQ of the programmers.
>>
>>106961559
buy an ad jewish niggerfaggot
>>
>>106961303
Now lets see the compilation times!
>>
>>106960353
never trust a retard to microbenchmark. that 60% might as well be pulled out of your ass.
>>
>>106962498
>>106962518
retard wrecked again (this is not the first time OP has made a thread for this. he suffers from c++ derangement syndrome.)
>>
>>106962044
0 is the most often compared against number, so comparing against 0 is faster than ither numbers on most hardware
>>
>>106962231
where is the compiler output for slow()? why are you looking at the same output window twice? are you stupid or just dishonest?
>>
>>106965418
this is why you're being replaced by indians
>>
>>106961423
The part that does the addition is practically identical. The rest is barely different, not enough to show up in any workload
>>
File: 1757769151212.png (81 KB, 1180x1051)
81 KB
81 KB PNG
>>106961629
This is the same guy who made this graph btw
>>
>>106960353
> function calls are slower
Yeah no shit, function calls incur overhead. Are you actually retarded?
>>
File: 1754963456161390.png (96 KB, 602x438)
96 KB
96 KB PNG
>>106970203
>function calls incur overhead
That's not the problem here, and not all function calls incur overhead
>>
>>106970379
Shutup cnt.
>>
>>106970572
Nocoder kvetching
>>
i don't get the obsession with rust in particular
>>
>>106965279
Wait, where is it destroying an object in the loop iteration?
>>
>>106969371
>where is the compiler output for slow()? why are you looking at the same output window twice?
Because I attached compiled to the same source code twice by accident duh.

>are you just dishonest?
Yeah because I am a committee-paid shill trying to trick people into using std::span or some other shit lmao.
>>
>>106971351
to be also fair, you're using a nightly of clang as well
>>
>>106971824
Feel free to use any other compiler.
>>
>>106961579
>just solve the halting problem bro
>>
>>106960353
int cunt



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.