Improve compile times

I have noticed that my compile times are growing. For example, if I change one resource file and compile, it takes about 8 seconds for the compilation to complete. I started out with a single Ash API, and I have now split this into two. However, compiling with the --verbose flag shows that all files in the the api of the modified resource are compiled (expected) however a number of resources from the other API are also recompiled. 23 files are recompiled in total. So, is 8 seconds to recompile 23 files on an M1 Macbook pro normal? Could the fact that I have cross-api relationships be contributing to this? 8 seconds doesn't sound bad, however as the application grows it could become a barrier to doing test driven development.
29 Replies
ZachDaniel
ZachDaniel•3y ago
🤔 that is interesting we take steps to prevent that kind of thing could you perhaps show me an example of another file that is recompiled when your resource is compiled? Or a few examples?
Alan Heywood
Alan HeywoodOP•3y ago
Gist
account.ex
GitHub Gist: instantly share code, notes, and snippets.
ZachDaniel
ZachDaniel•3y ago
🤔 you can use xref to potentially find some candidate causes mix xref graph --sink the_file_youre_compiling --label compile and mix xref graph --sink the_file_youre_compiling --label compile-connected
Alan Heywood
Alan HeywoodOP•3y ago
👀
Alan Heywood
Alan HeywoodOP•3y ago
Thanks, it sounds like this is unusual and it's probably something I'll have to hunt down. Here's the result of those xref commands https://gist.github.com/ahey/8761b580d8ce8a3277f6dee9c587ba02
Gist
gist:8761b580d8ce8a3277f6dee9c587ba02
GitHub Gist: instantly share code, notes, and snippets.
ZachDaniel
ZachDaniel•3y ago
🤔 This actually might be something we've done I'm wondering if our ecto association addition may have caused this 😢
Alan Heywood
Alan HeywoodOP•3y ago
I can try some older version of ash to see if that resolves?
ZachDaniel
ZachDaniel•3y ago
damnit yeah its the ecto association stuff 😢 okay, can you try this branch? no-relationships of ash
Alan Heywood
Alan HeywoodOP•3y ago
👀
ZachDaniel
ZachDaniel•3y ago
{:ash, github: "ash-project", branch: "no-relationships", override: true} should do it sorry just pushed another thing to it so if you pulled, pull again
Alan Heywood
Alan HeywoodOP•3y ago
Strangely, that branch does not exist
ZachDaniel
ZachDaniel•3y ago
try again?
Alan Heywood
Alan HeywoodOP•3y ago
Got it Hmm, this branch has not changed anything. Changing that 1 file results in the same 23 files being compiled.
ZachDaniel
ZachDaniel•3y ago
🤔
Alan Heywood
Alan HeywoodOP•3y ago
So it might be something i've done
ZachDaniel
ZachDaniel•3y ago
I don't think so, but possibly I just pushed another potential fix
Alan Heywood
Alan HeywoodOP•3y ago
👀 Unfortunately the issue persists
ZachDaniel
ZachDaniel•3y ago
okay round 3 try again 😆
Alan Heywood
Alan HeywoodOP•3y ago
👀 Yes!! That did it Only 3 files compiled
ZachDaniel
ZachDaniel•3y ago
Okay. So now I need to figure out if what I just did is actually okay 😆
Alan Heywood
Alan HeywoodOP•3y ago
I'll run my test suite as a start
ZachDaniel
ZachDaniel•3y ago
I think it should be okay
Alan Heywood
Alan HeywoodOP•3y ago
Finished in 3.4 seconds (3.4s async, 0.00s sync)
245 tests, 0 failures, 2 skipped
Finished in 3.4 seconds (3.4s async, 0.00s sync)
245 tests, 0 failures, 2 skipped
I love how fast my test suite is
ZachDaniel
ZachDaniel•3y ago
wait did they just get faster 😆 or do you just mean in general
Alan Heywood
Alan HeywoodOP•3y ago
No just in general 😄
ZachDaniel
ZachDaniel•3y ago
oh okay good. I was worried haha, if what I just did changed your test speed then shit definitely got weird I'll push it to main.
Alan Heywood
Alan HeywoodOP•3y ago
But the compile step of running tests is down to 1.6 seconds from 8 seconds when I change 1 file. Thanks for you help 🥳
ZachDaniel
ZachDaniel•3y ago
np 🙂 Its pushed to main, will be in a release at some point thanks for pointing out the issue
Alan Heywood
Alan HeywoodOP•3y ago
np

Did you find this page helpful?