tfutils / tfenv

Terraform version manager
MIT License
4.48k stars 454 forks source link

Disable bashlog.sh unless TFENV_DEBUG is higher than 0 #312

Closed reegnz closed 2 years ago

reegnz commented 2 years ago

Bashlog puts an unnecessary overhead on all terraform commands. If debug is not enabled, don't use bashlog, use a more lightweight log function instead.

Fixes #196 and #229

reegnz commented 2 years ago

Benchmarks

Before

❯ time ./terraform -version
Terraform v1.1.0
on darwin_amd64
./terraform -version  0.44s user 0.49s system 62% cpu 1.492 total

After

❯ time ./terraform -version
Terraform v1.1.0
on darwin_amd64
./terraform -version  0.06s user 0.04s system 77% cpu 0.130 total

I also made sure to keep the color coding of the log levels.

reegnz commented 2 years ago

@Zordrak can you please have a look? This issue has been plaguing quite a lot of people so it would be great to deal with this soon.

I also am preparing a fix for bashlog which would be equivalent to this change in performance.

reegnz commented 2 years ago

I also prepared #313 which is probably better than this one, as that is definitely backward-compatible (so no major version bump needed).

reegnz commented 2 years ago

I'm closing this in favour of #313