magefile / mage

a Make/rake-like dev tool using Go
https://magefile.org
Apache License 2.0
4.01k stars 250 forks source link

refactor(listGoFiles): remove go list dependency #440

Closed jaredallard closed 1 year ago

jaredallard commented 1 year ago

What this PR does: This PR removes the usage of go list in favor of parsing the files with the go/build package. This speeds up the discovery of go files from ms to us, which combined with MAGEFILE_HASHFAST can reduce the time for a re-run of mage to ~200ms.

I was getting a little irritated with every run of mage being at least 500-600ms due to go list taking a min of 200ms and being called twice, go list does a lot more then we were using it for. So, I propose we parse it instead.

Notes for my reviewer: I did this pretty quickly, and without that much regard for style. I'm happy to split this up and clean it up if we're OK with the approach. Thank you for reviewing :sparkles:

Related to https://github.com/magefile/mage/issues/404

Performance Measurements

This PR:

$ MAGEFILE_HASHFAST=true hyperfine -i './bin/mage -debug -l'
Benchmark 1: ./bin/mage -debug -l
  Time (mean ± σ):     182.7 ms ±   7.7 ms    [User: 33.5 ms, System: 84.2 ms]
  Range (min … max):   171.9 ms … 199.5 ms    14 runs

1.13.0:

$ MAGEFILE_HASHFAST=true hyperfine -i "$HOME/.asdf/installs/mage/1.13.0/bin/mage -debug -l"
Benchmark 1: /Users/jaredallard/.asdf/installs/mage/1.13.0/bin/mage -debug -l
  Time (mean ± σ):     529.2 ms ±  12.7 ms    [User: 196.9 ms, System: 433.4 ms]
  Range (min … max):   507.8 ms … 555.5 ms    10 runs
jaredallard commented 1 year ago

I probably should've created an issue for this first 😓, please let me know if you'd like me to do that, otherwise I'm happy to chat about this on here or on the Slack!

natefinch commented 1 year ago

This sounds pretty great. I'm busy this weekend but I can take a look tomorrow. Thanks a lot for this proposal!

jaredallard commented 1 year ago

This sounds pretty great. I'm busy this weekend but I can take a look tomorrow. Thanks a lot for this proposal!

Sorry to ping, but any update on a review? Totally understand if you're busy!

jaredallard commented 1 year ago

FYI I'm going to be using mage a lot more, I'd be happy to help drive some of the improvements here if you all have a priority list of some I could tackle! Thanks for the awesome project! ✨

jaredallard commented 1 year ago

Thank you so much @natefinch! Is there a timeline I could get for releasing this? Eager to get this through asdf 👀

natefinch commented 1 year ago

I can make a release tonight:)