Skip to content
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

More performance improvements by hiding expensive imports until they are needed #3

Open
wants to merge 2 commits into
base: lazy-cherry
Choose a base branch
from

Conversation

tpvasconcelos
Copy link
Owner

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


Relates to: bridgecrewio#6740

Description

In the same spirit of bridgecrewio#6740 and #1, this pull request tries to gain even more performance improvements using a similar approach of hiding expensive imports until they are needed.

While similar, the approach here is more generic and doesn't just tackle the effect of importing all runners and checks. It instead tackles the problem of eagerly importing expensive packages even when they will never be used in a given invocation. As a result, the effect can be large even when running all checks against a directory.

When comparing against the main branch, we see performance improvements of up to -71% when running simple commands like checkov --version but still significant improvements of around -24% when running all checkov checks (e.g. checkov -d .).

Please refer to the issue and PR mentioned above for more details on motivation and methodology.

Benchmark results

Comparing against the main branch

Eager Lazy pct
argv mean stddev mean stddev mean
--version 0.999 0.034 0.287 0.002 🔻-71%
--list 2.156 0.068 1.664 0.010 🔻-23%
--framework=openapi
-d tests/openapi/
0.940 0.022 0.303 0.013 🔻-68%
--framework=ansible
-d tests/ansible/examples/
0.941 0.037 0.299 0.002 🔻-68%
--framework=terraform
-d tests/terraform/checks/data
0.953 0.032 0.543 0.010 🔻-43%
-d tests/ 0.989 0.008 0.755 0.005 🔻-24%

Comparing against #1

Eager Lazy pct
argv mean stddev mean stddev mean
--version 0.552 0.019 0.287 0.002 🔻-48%
--list 1.869 0.014 1.664 0.010 🔻-11%
--framework=openapi
-d tests/openapi/
0.573 0.019 0.303 0.013 🔻-47%
--framework=ansible
-d tests/ansible/examples/
0.568 0.013 0.299 0.002 🔻-47%
--framework=terraform
-d tests/terraform/checks/data
0.802 0.045 0.543 0.010 🔻-32%
-d tests/ 0.947 0.011 0.755 0.005 🔻-20%

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant