sigmoid.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A social space for people researching, working with, or just interested in AI!

Server stats:

588
active users

Steve Leach

Wow.. So I was trying to some Rust code that would take six hours to run.

My goal was to get that down to 3.5 hours (something I'd achieved previously with lost code). Some tweaking got it down to 5 hours estimated runtime.

Then I thought to do:

"cargo build --release" instead of just "cargo build" for the first time.

And we're down to 3 minutes.... not 3.5 hours... 3 minutes.

Ok.. Good to know. Debug adds just a tiny bit of overhead on some code ;-).

I was convinced at first that the output couldn't be right. I was sure that *somehow* I'd written code that depended... somehow... mysteriously... on the debug stuff somehow???

But it writes out 500 checkpoints as it does it's job. So I grabbed two points, plugged into my Python code... waited.. waited... waited... and they checked out (same two states take seconds for the code to generate).

So... Yea... "--release" makes a *huge* difference.

@stevenaleach Yup! There's some especially bad patterns, and yours is one of the biggest differences i ever heard about, but yes, makes a huge difference.

If you want faster performance during development, you can also increase the opt-level:

opt-level 3 is what --release also uses

[profile.dev]
opt-level=3

or set it for just dependencies, which results in faster compile times if you don't need to recompile deps

[profile.dev.package."*"]
opt-level = 3

@stevenaleach
Hehe yeah, we've all been there. 😎

#optimize#rust#code

@chfkch

'Twas a first for me.

I was sure I had to have broken something somehow - I really didn't think it was possible for it to run that fast.

I figured I'd somehow introduced a bug that was short-cutting stuff... I squinted at it for a good long time trying to figure out what I'd screwed up before I verified the output and found my code really was 120 times faster and it was turning in good work.

@stevenaleach Rust debug builds (like many Rust things) give you more than you might be used to from other languages - integer overflow or underflow in a debug build will panic IIRC. It’s nice if you’ve managed to screw up your math.

@stevenaleach I had a similar experience a while back with some PNG stitching code. It went from several minutes to virtually instant execution. I found that quite perplexing...