perf(list_plugin): make test_map lazy - #336
Open
speriaswamy-amd wants to merge 2 commits into
Open
Conversation
main.py's discover_plugins() instantiates every plugin on every CLI invocation to build the argparse structure, regardless of which subcommand actually runs. ListPlugin computed test_map eagerly in __init__ via a full os.walk of cvs/tests/, so `list` and `run` (both ListPlugin subclasses) already walked the tree twice per invocation for nothing; a third subclass is coming next. Make it a lazily-computed property instead. AIMVT-276.
…rebase An earlier commit on this branch was built from a stale base and silently reverted main's fix that excludes private helper modules (e.g. _shared.py) from test discovery. Re-apply it alongside the lazy test_map property. AIMVT-276
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part 3 of 14 in a stack for AIMVT-276. Base: #335.
Why
main.py'sdiscover_plugins()instantiates every plugin on every CLI invocation to build the argparse structure, regardless of which subcommand actually runs.ListPlugin.__init__computedtest_mapeagerly via a fullos.walkofcvs/tests/, solistandrun(bothListPluginsubclasses) already walked the tree twice per invocation for no reason. A third subclass (man) is coming later in this stack, which would make it three.What changed
cvs/cli_plugins/list_plugin.py—test_mapis now a lazily-computed@propertybacked byself._test_map, walked on first access instead of at construction.cvs/cli_plugins/unittests/test_list_plugin.py— updated the one test that asserted discovery happened at construction time.