-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
potential slowness when dealing with large number of configuration values #11
Comments
as maybe you could start from doing argparse just once and then finding out what attributes it has and then checking the env vars / config based on that (also only once for all). |
see there for a monster: https://github.com/borgbackup/borg/blob/1.2.0a6/src/borg/archiver.py#L2465 |
Not sure scalability is the right phrasing for the issue you raise as it suggest that after X amount of configuration keys parse_it will cease working... I agree with your assessment that the more configuration keys needed the longer it will take so gonna change the title to something more descriptive of the problem |
It should also be noted that unless you're dealing with thousands of configuration values it should still be a matter of a fraction of a second to go over them all (or so at least the tests I've ran so far seem to suggest)... that been said there is always room for improvement, as well as the argparse pre-reading suggestion @ThomasWaldmann raised I think it may be wise to run some speed tests to find what part of the process is the slowest and focus on that as without it it's just guess works. |
besides speed, it is also an architectural thing. maybe it's just not an elegant way to do it like that. it just works by brute force somehow. :-) |
The slowest part seems to be when forcing an envvars to be upper-case, the following unit test takes ~114ms on my laptop:
where as the unit test of reading variables without them being forced to be upper-case takes <1ms on my laptop:
All other tests (cli args included) takes considerably less time then |
uppercasing some string is a quick operation. but you need to be careful that the tests are really the same other than that (hint: they are not) and that normal timing fluctuations on you multitasking machine might be way bigger than what you are measuring. |
Your right about the |
the way the code does it right now is that it does everything per configuration key:
if you have a lot of configuration keys, this will get slow.
The text was updated successfully, but these errors were encountered: