-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add parallelism to major chunk of hooks. Check Parallelism
section in README
#620
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As non-zero codes now can popup only in subshells, there is no more reason to keep that option in main shell
This reverts commit b6017f1.
MaxymVlasov
added
feature
New feature or request
hook/terraform_tflint
Bash hook
hook/terraform_fmt
Bash hook
hook/terraform_docs
Bash hook
estimate/2h
Need 2 hours to be done
hook/terraform_checkov
Bash hook
hook/terraform_validate
Bash hook
hook/terraform_tfsec
Bash hook
hook/terragrunt_validate
Bash hook
hook/terraform_providers_lock
Bash hook
hook/terrascan
Bash hook
hook/terragrunt_fmt
Bash hook
hook/tfupdate
Bash hook
labels
Feb 9, 2024
Co-authored-by: George L. Yermulnik <[email protected]>
MaxymVlasov
commented
Feb 13, 2024
yermulnik
approved these changes
Feb 13, 2024
MaxymVlasov
requested review from
antonbabenko and
robinbowes
and removed request for
robinbowes
February 13, 2024 13:33
MaxymVlasov
commented
Feb 14, 2024
MaxymVlasov
commented
Feb 14, 2024
…623) So, I found that `nproc` always shows how many CPUs available is. K8s "limits" and docker `--cpus` are throttling mechanisms, which do not hide the visibility of all cores. There are a few workarounds, but IMO, it is better to implement checks for that than do them >Workaround for docker - set `--cpuset-cpus` >Workaraund for K8s - somehow deal with [kubelet static CPU management policy](https://kubernetes.io/docs/tasks/administer-cluster/cpu-management-policies/#cpu-management-policies), as [recommend in Reddit](https://news.ycombinator.com/item?id=25224714) * Send all "colorify" logs through stderr, as make able to add user-facing-logs in functions that also need to return same value to the function-caller. Needed for `common::get_cpu_num` err_msg show up --------- Co-authored-by: George L. Yermulnik <[email protected]>
MaxymVlasov
commented
Feb 15, 2024
MaxymVlasov
commented
Feb 15, 2024
yermulnik
reviewed
Feb 15, 2024
Co-authored-by: George L. Yermulnik <[email protected]>
antonbabenko
approved these changes
Feb 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG! It seems to work as expected
Yeah, that's a bit of magic by Max 😄 |
antonbabenko
pushed a commit
that referenced
this pull request
Feb 17, 2024
# [1.87.0](v1.86.1...v1.87.0) (2024-02-17) ### Features * Add parallelism to major chunk of hooks. Check `Parallelism` section in README ([#620](#620)) ([6c6eca4](6c6eca4))
This PR is included in version 1.87.0 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
estimate/2h
Need 2 hours to be done
feature
New feature or request
hook/terraform_checkov
Bash hook
hook/terraform_docs
Bash hook
hook/terraform_fmt
Bash hook
hook/terraform_providers_lock
Bash hook
hook/terraform_tflint
Bash hook
hook/terraform_tfsec
Bash hook
hook/terraform_trivy
Bash hook
hook/terraform_validate
Bash hook
hook/terragrunt_fmt
Bash hook
hook/terragrunt_validate
Bash hook
hook/terrascan
Bash hook
hook/tfupdate
Bash hook
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Put an
x
into the box if that apply:Reasoning
We have a GH workflow that runs lockflies updates every week (implementation and reasoning here).
It usually takes from 2h 30min to 3h 15min. That was fine for us, till we found that our GH runners, based on AWS EC2s, started silently failing after 30min "without recent logs", and that was fixed by crutch which sends a dummy log every 10min.
However, during the debugging, I spent some time describing why hooks were not utilizing all the provided resources.
And that means a waste of time and money, not only for that corner case but for every huge commit, which can cause opting out by
git commit -n
of using hooks locally for changes that affect many directories.Description of your changes
--parallelism-limit
setting to--hook-config
. Defaults tonumber of logical CPUs - 1
Main implementation usesflock
, which not pre-installed in macOS and some ancient BSD/Linux systems.To maintain backward compatibility, for cases where noflock
- fallback to "bash-native locking mechanism" was added.t init
in parallel.t init
directory.In quick tests, I can say that on big changes:
Withflock
, there 300-500% speed increase for most of the hooks.Withoutflock
, there 250-450% speed increase for most of the hooks.terraform_validate
, and up to 500% - for other affected hooks.--parallelism-limit=1
I observed an insignificant increase in time (about 5-10%) compared to v1.86.0 which has no parallelism at all. This may be the cost of maintaining parallelism or the result of external factors since the tests were not conducted in a vacuum.For small changes, improvements are less significant.
How can we test changes
There is no easy way to test it, but that could be used as a testing template