-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] Add concurrency for "download-syntax" module & support many args for --only parameter #19
Conversation
Oops, there's no |
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.
this should be split into 4-5 separate changes instead of all in one
some things:
- this is only run interactively and speed isn't really an issue (even after converting to a threadpool it looks like it only improved it by ~40% -- I don't think the introduced complexity is worth that). if this were in the critical path of something then sure the change is worth it
- I personally don't like pathlib, you can accomplish all the same things with
os.path.join
-- additionally I see someas_posix()
which means pathlib is actually harmful to correctness here :) - there are far too many changes in this patch to review it properly, I started reviewing it but then realized just how long this is -- ideally keep things in small, reviewable changes (and only move code around when necessary)
_GRAMMAR_DIR = 'share/babi/grammar_v1' | ||
_LICENSE_DIR = 'licenses' | ||
_GRAMMAR_DIR = Path('share/babi/grammar_v1') | ||
_LICENSE_DIR = Path('licenses') |
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.
I really don't like pathlib sorry
parser.add_argument('--only') | ||
# "extend" is a 3.8+ action, which allows passing multiple arguments | ||
# to the same command, e.g. ./app --foo 1 2 3 -> {'foo': ['1', '2', '3']} | ||
parser.add_argument('--only', action='extend', nargs='+', type=str, default=[]) |
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.
action='append' is a better experience anyway
')\n' | ||
'REPOS = (\n' + | ||
''.join(f'{textwrap.indent(repr(r), " " * 4)},\n' for r in up_to_date_repos) + | ||
')\n' |
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.
why did this change indent
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.
Uh, sorry, I probably messed up something in my IDE.
Hi Anthony! Thanks for the comments! :-) Yeah, I agree, mixing all the things into one huge PR was a mistake. I will answer your questions anyway and close this PR as it is not unsuitable for the merge. It is a good experience for me though!
It is almost x10 boost for the
While I understand that it is a personal preference either to use Thanks for your time! |
oh yeah, I think a lot of parts of this are salvageable though and could be split out into separate PRs! splitting commits after the fact can be kind of trick -- the way I've done it in the past ~essentially involves:
|
Thanks, Anthony!
That's what I will do. :-)
I am closing this PR ^^ |
sounds great! |
ThreadPoolExecutor
) downloads for the_download
command, had to refactor it a bit and break into smaller piecesOn 4 cores,
python .\bin\download-syntax download
:Before: 33-47s
After: 4.9-5s
ThreadPoolExecutor
) for the_update
commandOn 4 cores,
python .\bin\download-syntax update
:Before: 75-82s
After: 37-39s
Well, not THAT huge difference, but I suppose
moby/moby
repo is the bottleneck here, it takes forever to process itstderr
, other tasks continue to work; we don't want to waste things we already processed :-)pathlib.Path
objects when possible; it allows to make reproducible results on both Linux and Windows (slashes/backslashes, uh-oh)encoding='utf-8'
parameter to allopen
calls, because on some locales on Windows it creates files with incorrect symbols--only
parameter for both_download
and_update
commands. Now you can dopython .\bin\download-syntax download --only MagicStack/MagicPython asottile/language-xml
orpython .\bin\download-syntax download --only MagicStack/MagicPython --only asottile/language-xml
, both "styles" should work (warning: it is a 3.8+ feature (scroll down to theextend
action)Yes, I messed up and all the changes were added to a single commit. Sorry!
If you are interested in something particular from the list - please, let me know and I will create a separate PR for it.
If it looks good enough - I may add changes to the README. Let me know what you think. :-)
P. S. I learned my lesson