Showing prefix of the site that has many prefixes is slow #5422

Closed
opened 2025-12-29 19:27:47 +01:00 by adam · 6 comments
Owner

Originally created by @shuichiro-makigaki on GitHub (Sep 25, 2021).

Originally assigned to: @shuichiro-makigaki on GitHub.

NetBox version

v3.0.3

Python version

3.9

Steps to Reproduce

  1. Add a site and some prefixes under the site. (The site has 48 prefixes in our environment, and some of them have some child prefixes. One of them has over 30 child prefixes.)
  2. Click site from the left menu, select the added site, click prefix on the right corner of the site page.

Expected Behavior

The prefix page of the site shows within seconds.

Observed Behavior

It took around 40 seconds to show 50 prefixes on a page.

Calculation of prefix utilization seems to consume a lot of execution time: after hiding the utilization bar (%) by "Configure Table," it took 1 second to show.
I'm preparing a Pull Request to optimize the utilization calculation.

Originally created by @shuichiro-makigaki on GitHub (Sep 25, 2021). Originally assigned to: @shuichiro-makigaki on GitHub. ### NetBox version v3.0.3 ### Python version 3.9 ### Steps to Reproduce 1. Add a site and some prefixes under the site. (The site has 48 prefixes in our environment, and some of them have some child prefixes. One of them has over 30 child prefixes.) 2. Click site from the left menu, select the added site, click prefix on the right corner of the site page. ### Expected Behavior The prefix page of the site shows within seconds. ### Observed Behavior It took around 40 seconds to show 50 prefixes on a page. Calculation of prefix utilization seems to consume a lot of execution time: after hiding the utilization bar (%) by "Configure Table," it took 1 second to show. I'm preparing a Pull Request to optimize the utilization calculation.
adam added the type: bugstatus: accepted labels 2025-12-29 19:27:47 +01:00
adam closed this issue 2025-12-29 19:27:47 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 27, 2021):

It took around 40 seconds to show 50 prefixes on a page.

It sounds like you have something else going on with your deployment. I was not able to reproduce the reported behavior even using several hundred prefixes. Additionally, running NetBox with your proposed change in PR #7366 did not have any noticeable effect on the load time.

Please update your post above to prescribe the exact number and types of objects you are creating to reproduce this behavior. How many total prefixes, and of what type (container vs non-container)? How many child prefixes per parent? How many IP ranges? How many IP addresses?

@jeremystretch commented on GitHub (Sep 27, 2021): > It took around 40 seconds to show 50 prefixes on a page. It sounds like you have something else going on with your deployment. I was not able to reproduce the reported behavior even using several hundred prefixes. Additionally, running NetBox with your proposed change in PR #7366 did not have any noticeable effect on the load time. Please update your post above to prescribe the *exact* number and types of objects you are creating to reproduce this behavior. How many total prefixes, and of what type (container vs non-container)? How many child prefixes per parent? How many IP ranges? How many IP addresses?
Author
Owner

@shuichiro-makigaki commented on GitHub (Sep 28, 2021):

This is an example of prefixes on the site.
capture
The total utilization of this prefix is 55%, but it took 15~20 seconds to open the "Prefix" tab.

I'd like to provide (anonymized) exported data of the site (or the prefix) to reproduce the problem, but don't know how to export data of a specific site only.

@shuichiro-makigaki commented on GitHub (Sep 28, 2021): This is an example of prefixes on the site. ![capture](https://user-images.githubusercontent.com/8788139/135019501-86d69c95-a5b3-4902-86dd-69aad44ce1c2.png) The total utilization of this prefix is 55%, but it took 15~20 seconds to open the "Prefix" tab. I'd like to provide (anonymized) exported data of the site (or the prefix) to reproduce the problem, but don't know how to export data of a specific site only.
Author
Owner

@DanSheps commented on GitHub (Sep 28, 2021):

Shuichiro,

We need detailed steps as we cannot reproduce this. So, starting from site creation, please detail the steps such as:

  1. Create a site
  2. Create a device
  3. Create a container prefix
  4. Create a child prefix
  5. Repeat step 4 until there is 50% utilization

We also need to be able to reproduce this, so confirm that your steps are correct by creating a development instance. In a pinch you can use the demo site but the key is we need to be able to reproduce this.

@DanSheps commented on GitHub (Sep 28, 2021): Shuichiro, We need detailed steps as we cannot reproduce this. So, starting from site creation, please detail the steps such as: 1. Create a site 2. Create a device 3. Create a container prefix 4. Create a child prefix 5. Repeat step 4 until there is 50% utilization We also need to be able to reproduce this, so confirm that your steps are correct by creating a development instance. In a pinch you can use the demo site but the key is we need to be able to reproduce this.
Author
Owner

@jeremystretch commented on GitHub (Sep 28, 2021):

The key detail here that seems to have been omitted is that you're creating a very large number of child IP addresses within each prefix. I can confirm that the approach suggested in #7366 does yield better performance in such a case.

@jeremystretch commented on GitHub (Sep 28, 2021): The key detail here that seems to have been omitted is that you're creating a very large number of child IP addresses within each prefix. I can confirm that the approach suggested in #7366 does yield better performance in such a case.
Author
Owner

@DanSheps commented on GitHub (Sep 29, 2021):

A little off topic, but, is there anywhere else where this approach could be applied to yield better performance?

@DanSheps commented on GitHub (Sep 29, 2021): A little off topic, but, is there anywhere else where this approach could be applied to yield better performance?
Author
Owner

@shuichiro-makigaki commented on GitHub (Sep 29, 2021):

Thank you for your understanding.

A little off topic, but, is there anywhere else where this approach could be applied to yield better performance?

Prefix.get_available_ips() in ipam/models/ip.py has the same logic using IPSet.add() in a loop.
My Python IDE says it's the only occurrence of the add method, but actually, I cannot guarantee that.

@shuichiro-makigaki commented on GitHub (Sep 29, 2021): Thank you for your understanding. > A little off topic, but, is there anywhere else where this approach could be applied to yield better performance? `Prefix.get_available_ips()` in `ipam/models/ip.py` has the same logic using `IPSet.add()` in a loop. My Python IDE says it's the only occurrence of the `add` method, but actually, I cannot guarantee that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5422