iced icon indicating copy to clipboard operation
iced copied to clipboard

Any way to increase iteration speed?

Open yay opened this issue 3 years ago • 15 comments

Hello, I'm playing with the basic examples, like a single button changing the window title on click. But every time I run the app after making a change to the title string it takes a little over 10 seconds to recompile (on a 16" i9 MBP).

This is really disappointing coming from both web apps and native apps (Swift/SwiftUI, Delphi/VCL or C++/Qt based). At least when we are talking about basic apps like this.

Any way to improve this? I know the native frameworks I mentioned use dynamic libraries for the framework code while Rust has to recompile from source, but I'm really wondering about solutions rather than reasons for slow compile times.

I'm using the recently released iced 0.2 and Rust 1.48 on macOS 11.1

yay avatar Nov 26 '20 23:11 yay

Maybe ramdisk will help you?

yaskhan avatar Nov 27 '20 03:11 yaskhan

It's true that Rust has a slow compile time for several reasons, but 10 seconds for that is way too much. I'm suspicious it could be a hardware issue (from what I gathered, not sure if the 16" model has the same issue) as my air-cooled Ryzen 5 2400G recompiles my quite substantial hexview demo in half that time when changing a couple lines, sometimes even a little bit less.

But there's a way to reduce compile times a little bit, described here. Might be worth a try.

manokara avatar Nov 27 '20 14:11 manokara

I don't believe it's thermals related, the 16" model has a redesigned body with much larger air intakes and bigger fans to improve airflow. But it shouldn't make a difference either way compiling what is essentially a Hello World app from idle.

I don't believe it's IO bound either, I had a Ryzen 3900X PC with 1TB Evo 970 NVMe SSD that compiled our whole monorepo at the same speed (slightly slower actually, maybe because Windows...) as this laptop.

yay avatar Nov 28 '20 20:11 yay

Use cargo build incremental https://doc.rust-lang.org/cargo/reference/config.html

alex13sh avatar Nov 30 '20 08:11 alex13sh

Adding

[build]
incremental = true

to ./cargo/config.toml doesn't seem to do anything: Screen Shot 2020-12-02 at 19 41

yay avatar Dec 02 '20 19:12 yay

That's because in debug builds incremental is enabled by default. Have you tried the linker approach I mentioned in my previous post? Still, I can't see a reason why an i9 would be slower than a 2nd gen Ryzen, even if it's a mobile chip. What could possibly be going on?

manokara avatar Dec 02 '20 20:12 manokara

Thanks @manokara, I just tried that (was a bit busy at the time). With rustc 1.50 nightly and zld 1.2.1 the debug build now takes 6.29s, which is obviously a massive difference 👍, although I wouldn't mind improving it further :)

yay avatar Dec 03 '20 00:12 yay

One thing I noticed is that after upgrading to macOS 11.0.1 VS Code got slower because of this issue: https://github.com/microsoft/vscode/issues/105446#issuecomment-729274600 I wonder if it plays a part here.

yay avatar Dec 03 '20 00:12 yay

These tweaks worked really well for me, check out the PR I referenced :point_up:

cryptoquick avatar Dec 13 '20 21:12 cryptoquick

Thanks @cryptoquick, they worked for me too, that's what I was referring to here: https://github.com/hecrj/iced/issues/638#issuecomment-737570512 Although, as manokara suggested, there must be a reason why my builds are twice as slow even after tweaks on a seemingly comparable CPU (over 6 seconds vs under 3).

yay avatar Dec 13 '20 21:12 yay

@yay If you're currently using a Mac that costs less than $5000, you're almost definitely not using a comparable CPU. My CPU has a TDP of 105W. However, I also noticed that your build key recommendation seemed to be ignored in my screenshot, as I understand @manokara pointed out. Are you using zld, like the bevy instructions indicated? You also have to add the .cargo/config.toml, and be using nightly.

EDIT: I just read the comment you linked, haha, I'm tired. Yeah, that's what I did too, just with lld on my LInux desktop.

cryptoquick avatar Dec 13 '20 21:12 cryptoquick

@cryptoquick Haha, no worries, sadly, I am using a MBP that is worth £4000 with i9-9980H inside. And reading tweets like this makes me think I'll have to upgrade next year: https://twitter.com/rikarends/status/1328598935380910082

yay avatar Dec 13 '20 21:12 yay

@yay Hold out for the M1X :wink:

cryptoquick avatar Dec 13 '20 23:12 cryptoquick

@cryptoquick I did :) and it's a big help! Now waiting for mold to come to macOS 😛

yay avatar Apr 26 '22 21:04 yay

https://github.com/iced-rs/iced/issues/21

13r0ck avatar Apr 26 '22 22:04 13r0ck