« first day (2402 days earlier)      last day (1069 days later) » 

4:52 AM
I thought for a moment you were referring to my binary expression tree crate...
(https://crates.io/crates/bet)
 
 
8 hours later…
12:40 PM
Someday I'll understand where the upvotes come from
2
 
Mainly from users, as far as I know.
 
:slight_smile:
I mean that there are questions with a strange modality
With more than "usual" upvotes or downvotes for their age
 
I will say cause most people are like most people
also I see a user4631665465 something upvote every question he answer
even very bad one
 
1:13 PM
@Stargateur well, if that were the case, then that would just be a usual +1 :-)
 
1:36 PM
I mean, surely may be some aversion to "why is this Rust code slower than this one in Whatever", but if they don't even bother making a proper MRE, it's pointless.
 
@E_net4thejanitor I think that @trentcl wins the guess on this one
But your bigint difference was my guess
 
Should cargo now identify and warn about running cargo run followed by cargo build --release? :|
 
No MRE, too wide, there's no reason for this question to be on SO
 
One CV left.
Osht, keeping a Python REPL open was bringing my System interrupts service up to 96% CPU usage.
 
That was just python trying to slow down your computer while you were benchmarking rust
 
1:51 PM
x)
I could not even run the Python code. OverflowError: int too large to convert to float
 
Python 2 or 3?
 
Python 3.9
I mean, if that is Python 2, that would be yet another reason to downvote.
 
2:06 PM
The "collect all numbers into a string to print them" makes me sad
but at least it's consistent between the two
 
2:29 PM
> Edit: It was definitely the BigUint that was slowing the whole thing down. Without using BigUint the program finishes in under 2 seconds. Sorry for the confusion I caused.
huh
 
I don't understand why my speeds were so different
 
@Stargateur congratulations on the effort of writing random digits after user :P
unrelatingly, I'm really hyped about this pot-au-feu of beef slow-cooked with stout beer I made yesterday, and I really need to ventilate my emotions. it's really good.
 
@Shepmaster Mine were definitely different from what you commented: 57s in Rust vs 28s in Python.
 
@E_net4thejanitor wild! I did it on WSL2 with Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz 4.01 GHz & 16.0 GB
 
2:44 PM
This one's an Intel Core i7-6700HQ @ 2.60 GHz 2.60 GHz, running directly on Windows.
I did change the code a bit to just make it print to stdout instead, then piped it to a file when calling. Not sure how much that would affect the times.
 
I changed mine a bit to add newlines so I could diff the rust and python output easier to make sure I got the same arguments
but doesn't seem like that should be that much
 
Would opt-level=3 make a difference?
Apparently not.
But there are many more differences in the two programs. I don't see Python creating a list of float numbers.
 
I'm gonna open a new question: why do I and @E_net4thejanitor get different results on these Python and Rust programs?
 
@Shepmaster Better double-check what we're running first. Care to share your version of the Rust code? :)
 
The current version of the question has copy-pastable code for both language now, that's what I used
it did change to 10s for Rust and 17s for Python
 
2:54 PM
Imma take that then.
I also noticed that the file writer isn't buffered, but we're writing a single string here.
 
3:29 PM
Functional programmers have a different brain than I do
 
brain
That flat map doesn't help
You need a higher ranked flat map
Or is it a monadic flat map
Monoidal result in the category of flat functors
my brain ne funkcias
cerbo*
 
@PeterVaro tute ne
 
If you need another machine as benchmark tie breaker, I'm always happy to execute random code from stangers on the internet!
 
@LukasKalbertodt >:)
 
3:40 PM
@E_net4thejanitor Excusez moi?
The correct answer would've been: I believe I did, Peter.
 
@PeterVaro Mi kredas, ke jes, Petero.
 
But no one speaks elvish..
Relevant article. (TBF, I never took the time to investigate on the points the OP makes, so I'm happy to hear counter arguments!)
 
Intriguing article, thanks for sharing.
@Shepmaster That sounds like we're reaching the point where the OP replies "I just don't know how to do that".
Tried running the thingy again: 48.7s was the best I got.
 
-2
Q: Why is a Rust iterative prime finding algorithm slower than the equivalent Python version, even in release mode?

ChillkroeteEdit: It was definitely the BigUint that was slowing the whole thing down. Without using BigUint the program finishes in under 2 seconds. Sorry for the confusion I caused. I wrote this prime finding algorithm to compare the speed of Rust and Python. The Rust program runs slower than the equivalen...

I guess I did make some changes - printed to two different files and added a newline to the Rust one
$ time python3 ./code.py

real    0m17.071s
user    0m16.971s
sys     0m0.100s
$ time ./target/release/so

real    0m10.999s
user    0m10.989s
sys     0m0.010s
@E_net4thejanitor Definitely time for a new computer though
 
@Shepmaster This ain't my personal one. 🤫
And that does not justify the performance against the Python program.
 
4:27 PM
I'm not going to do it, and I would never advise you to do it, but still, I'm very much interested where this goes and how long it's going to work...
 
@Shepmaster On WSL2, Ryzen 5 3600
    $ time python3 python.py

    real    0m12.673s
    user    0m12.632s
    sys     0m0.040s

    $ time ./target/release/test_rust

    real    0m8.839s
    user    0m8.809s
    sys     0m0.030s
 
:s
then who was phone
 
$ rustc --version
rustc 1.53.0-nightly (42816d61e 2021-04-24)
$ python3 --version
Python 3.8.5
FWIW
 
$ rustc --version
rustc 1.51.0 (2fd73fabe 2021-03-23)
$ python3 --version
Python 3.8.5
 
Gotta try it my personal laptop now.
 
4:41 PM
@E_net4thejanitor that work laptop has a speed limiter
 
Or is, you know, just getting a bit old
❯ time ./target/release/print-primes

real    0m10.989s
user    0m10.932s
sys     0m0.038s

❯ time python main.py

real    0m13.095s
user    0m13.018s
sys     0m0.063s
❯ rustc --version
rustc 1.52.1 (9bc8c42bb 2021-05-09)
❯ python --version
Python 3.9.4
 
Looking at the code right now. This is super weird, no? The maximum number that is dealt with here fits in u32. And the code uses bigints, u128 and f64 to represent all of that. What. Or am I missing something?
 
The OP admitted that the decision to use bigints was poor.
And yes, the use a vector of f64 at some point was unfounded and does not match what the Python program does.
 
Ah yeah ok. Was a bit confused
Finding all primes below 10^7 shouldn't take that long..
 
5:00 PM
A realistic scenario would have employed the sieve of Eratosthenes, methinks.
 
Mhhh should Rust have integer square root in std?
 
Maaayybe. But what would happen on (-1).sqrt()?
 
@E_net4thejanitor Only unsigned ints then?
I often show people how to write a primality test in Rust with iterators. Just to show off what's possible. E.g. (2..n).all(|d| n % d != 0). But if there was a integer sqrt, that would mean a decently fast version would still be very short and without ugly as casts.
 
I don't quite know what would make a fast and accurate implementation. If it still involves converting to a float and back, this could hide some heavy ops.
 
5:20 PM
@Stargateur anyhow is more Go than Java anyway
 
same thing
 
Not even
@Stargateur I like you so much. I feel you and I have a real dynamic going on.
I still feel like it's a mess to have all the error handling logic all over the place
Especially if you're writing a web server
With anyhow you can centralize all the downcasting into one place and translate errors into proper responses / log them all in one place
 
I centralized all my downcasting in the trash can
 
This is too much abuse
Downcasting is unfortunate
But the point is in centralizing error handling
Not downcasting
 
I'm allergic to dynamic dispatch doctor said
 
5:31 PM
And I centralized my error handling without downcasting, is my point :-)
 
It's a pain in the ass
I can't spend all day mapping errors around
 
I need to have a product too
 
What's unfortunate is that Warp forces me to put my error into a trait object to start with
so I do have some downcasting before I get to my nice error enum
 
Fair enough
That's good too
Why do you hate downcasting so much?
Other than performance
Or is that it
 
5:33 PM
you loose type information
I hate that
 
Sometimes you want to lose type information :P
 
maybe you, not me
 
Doesn't have to be a bad thing
 
I don't mind converting to a trait object in cases
it's the concept of "i don't care what concrete type this is" followed by "i now care what concrete type this is" that bothers me
 
If I put it like this: "I don't care what type this is, except if it's this or this or this. But if it's none of those, yeah I still don't care."
 
5:36 PM
exactly, so almost never
 
@E_net4thejanitor fwiw: play.rust-lang.org/…
Simple iterators: 8.60s
Sieve of Eratosthenes: 126.82ms
In case I even implemented it correctly. Did it from memory, which might be broken. shrug
 
well sieve is obviosuly faster as long as you have the memory
 
Who'd have thought huh @Stargateur
 
@LukasKalbertodt I feel like there's an article out there about how most sieves aren't the actual Sieve
 
@LukasKalbertodt I used the following some time ago
fn is_prime(n: u64) -> bool {
    match n {
        _ if n < 2 => false,
        _ if n < 4 => true,
        _ if n % 2 == 0 || n % 3 == 0 => false,
        _ => (5..=(n as f64).sqrt() as u64)
            .step_by(6)
            .all(|i| n % i != 0 && n % (i + 2) != 0),
    }
}
 
5:45 PM
@Shepmaster Probably :D I also first implemented it completely wrong. Might still be very wrong.
 
> A much beloved and widely used example showing the elegance and simplicity of lazyfunctional programming represents itself as “The Sieve of Eratosthenes”. This paper showsthat this example isnotthe sieve, and presents an implementation that actually is.
 
> starting from p²
First bug in my code found, great
 
6:00 PM
For what it's worth, the above ran in 3s (Ryzen 2600). Curious to see what you'll make of it.
 
6:58 PM
24
Q: Outdated Answers: flagging exercise begins today

Anita TaylorAs I mentioned last month, the next step in the Outdated Answers initiative is an exercise for flagging outdated answers. Starting today, you may see temporary prompts on Stack Overflow that ask if an answer is outdated. The prompts have a chance to appear when the accepted answer is at least 60 ...

 
7:14 PM
stackoverflow.com/q/67509637/155423 asking multiple questions
also
stackoverflow.com/q/67509690/155423 asking multiple questions
Cancel that first one
OP edited
(amazing)
 

« first day (2402 days earlier)      last day (1069 days later) »