-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use look-up-table and threading for major speed improvements #2
base: master
Are you sure you want to change the base?
Conversation
Speeding up queries See merge request atlas-admins/netbox-dnsmasq!1
Hi, Thank you for your contribution! Could you please fix the linting issues the CI pipeline threw? I'll have a look at the PR later tonight. |
gladly, if I completely understood them :-( . Shall I also try to address the previously present linting issues? pylint throws a lot of stuff like
already at aa6b134 at me |
I do not use pylint. You can find the linters that are being run and their options in the GitHub workflow here https://github.com/p-rintz/netbox-dnsmasq/blob/master/.github/workflows/linter.yml Otherwise, I can also have a look later tonight. |
I will likely need a few more days, as Im using this as a chance to enable others to run the tests more easily. |
no problem and after "fixing" the |
I have a question that Im a bit confused about. A look-up-table doesnt seem to help there, since the API call for the IP is happening regardless. Is the speed-up tied to the threading and not the lut? |
Interesting. When it was slow, I ran
Yes and no. In my testing, getting all LUT information in one go was much faster the individual calls. Weird.
LUT brought the major speed-up, threading "only" a factor of 2 at the end. I"m currently on vacation, but maybe I'll try to setup a larger "fake" netbox instance and test some more. |
The call that I meant (that is happening regardless) is in this line. I started a debugger and set various breakpoints (including in pynetbox) to see when the call was happening, and the mac address always seemed available right from the start of the for loop. I might simply be missing something, but Im trying to understand what exactly is happening and when 😃 |
I have not forgotten this PR but way too much on my plate at the moment. Odd think, yesterday I created a mock-up netbox system with 1000 servers and 3 IPs/system and both main tree and the PR branch were equally fast (13s on my laptop). Thus, I'll need to dig deeper why our evolved netbox instance is behaving differently. |
Currently, our netbox instance holds more than 3000 devices and more than 10k interfaces and IPs and creating an updated set of configuration files took more than 10 minutes.
The root problem seemed to be the API call to get the MAC address of the associated interfaces within the
prefix
loop. Adding a look-up-table greatly reduced run time to about 80s. Adding threading to the API instantiation got us another factor of 2 in speed-up.(I hope this PR is good enough, I rarely do these on github. And sorry that unrelated commit 375d41e is also in here - I needed that to be able to call the script directly (
./netbox_dnsmasq.py
) - if you disagree with that one, I can try removing it)