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

Speedup modify module #70475

Merged
merged 6 commits into from Jul 9, 2020
Merged

Speedup modify module #70475

merged 6 commits into from Jul 9, 2020

Conversation

sivel
Copy link
Member

@sivel sivel commented Jul 6, 2020

SUMMARY

This PR implements a few performance enhancements to our ast.NodeVisitor to speed up traversing the AST.

  1. Implement a function lookup table, instead of using getattr
  2. Override generic_visit to not call visit, eliminating function calls
  3. Override generic_visit to not walk expr objects, as imports can only happen within stmt
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/executor/module_common.py

ADDITIONAL INFORMATION

cProfile of recursive_finder before this change:

     26/1    0.006    0.000    0.247    0.247 executor/module_common.py:696(recursive_finder)

After:

     26/1    0.005    0.000    0.162    0.162 executor/module_common.py:719(recursive_finder)

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. performance support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 6, 2020
@sivel sivel marked this pull request as ready for review July 8, 2020 18:49
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 8, 2020
Copy link
Member

@nitzmahone nitzmahone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking your/CI's word for it that it still properly descends into imports in try/except, etc. ;) Nice little savings!

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 8, 2020
@sivel sivel merged commit c4fd5be into ansible:devel Jul 9, 2020
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jul 9, 2020
@ansible ansible locked and limited conversation to collaborators Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. performance support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants