Skip to content
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

Nautobot ORM actions slow when performed in the context of a Job after upgrading to v1.2 #1638

Closed
Tracked by #1615
wvandeun opened this issue Apr 13, 2022 · 3 comments · Fixed by #1641
Closed
Tracked by #1615
Assignees
Labels
type: bug Something isn't working as expected
Milestone

Comments

@wvandeun
Copy link

Environment

  • Python version: 3.8.12
  • Nautobot version: v1.2.5, v1.2.11

We are using Nautobot jobs to provision new sites, updating existing sites with new designs, etc etc.
After the upgrade to 1.2 (tested with 1.2.5 and 1.2.11), we noticed that these jobs take significantly more time to complete compared to 1.1 (tested with 1.1.6).

Specifically we see that certain ORM actions seem to be slower. We experience it when setting tagged VLANs on an interface or when setting a tag on an interface.Executing these actions outside of the context of a job (for example nbshell) behaves normally and fast.

vlans = VLAN.objects.filter(site__slug="somesite")[0:10]
interface = Interface.objects.get(
    name = "GigabitEthernet0/1",
    device = device
)

# slower
interface.tagged_vlans.set(vlans)

tags = {f"tag{i}" for i in range(10)}
for tag in tags:
   interface.tags.add(tag)

The slowness of the ORM actions in jobs seems to have a relation to the amount of change-log records in the db.
Attached you can find a job that we have used for testing.

  • v1.1.6 (no change-log records) takes +-2m5s
  • v1.1.6 (100k change-log records) takes +-2m
  • v1.1.6 (3m change-log records) takes +-2m
  • v1.2.5 (no change-log records) takes +- 2m30s
  • v1.2.5 (100k change-log records) takes +- 4m
  • v1.2.5 (3m change-log records) takes +- 40m (doesn't finish before NAUTOBOT_CELERY_TASK_SOFT_TIME_LIMIT is reached)

I did the tests on a completely dummy created data set, to exclude any weird things in our data set.

Steps to Reproduce

  1. Create a significant amount of changelog records (>100K)
  2. Execute this job in Nautobot v1.2 or above

Expected Behavior

Would expect the job to finish in the approximately the same time as when using earlier versions of Nautobot.

Observed Behavior

Job takes significantly more time to execute, compared to earlier versions of Nautobot.

@jathanism
Copy link
Contributor

@wvandeun One quick question as I'm about to sit down with this: When you say changelog records you do mean specifically actual ObjectChange objects? I just wanted to clarify between those and JobLogEntry objects, which were introduced in v1.2, to store job log entries as individual rows.

I intend to review both, but just wanted that clarification. Thanks!

@wvandeun
Copy link
Author

I mean ObjectChange objects with that.

@wvandeun wvandeun changed the title Nautobot ORM actions when performed in the context of a Job after upgrading to v1.2 Nautobot ORM actions slow when performed in the context of a Job after upgrading to v1.2 Apr 13, 2022
@jathanism jathanism added type: bug Something isn't working as expected status: accepted and removed workflow: under review labels Apr 14, 2022
@bryanculver bryanculver added this to the v1.3.0 milestone Apr 15, 2022
bryanculver added a commit that referenced this issue Apr 15, 2022
@bryanculver
Copy link
Member

Closed with #1641

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants