perf(migration): batch endpoint tags and restore inheritance#15311
Open
AKSHATSPAR wants to merge 2 commits into
Open
perf(migration): batch endpoint tags and restore inheritance#15311AKSHATSPAR wants to merge 2 commits into
AKSHATSPAR wants to merge 2 commits into
Conversation
AKSHATSPAR
force-pushed
the
fix/15124-bulk-migration-tags
branch
from
July 22, 2026 01:56
da71a5e to
16c9792
Compare
AKSHATSPAR
marked this pull request as ready for review
July 22, 2026 05:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a bug fix for #15124, not a new enhancement.
Description
The reporter's completed migration, whose progress output initially listed 65,194 Endpoints, attributed 115,317.36 seconds (99.8% of its measured phase time) to tags and required several restarts. The command copies tags separately for each tagged Endpoint; in a controlled rerun of the exact PR base, those writes also increased Tagulous counters without creating new relationships.
This PR:
LocationManager._bulk_inherit_tagscall removed by perf(tag inheritance): batch_mode + per-batch bulk during import + reorganize #14877, restoring first-pass Product-tag inheritance when enabled.Tests
Added focused coverage for full and partial batches, duplicate Locations, clean reruns, inherited tags, atomic rollback, and per-Endpoint recovery.
Local validation: 3 migration tests passed, 29 bulk-tag tests passed, and 39 inheritance tests completed (37 passed, 2 skipped). Django system and migration checks and Ruff also passed.
Controlled comparison
I compared the exact PR base (
22e2519) and patch in two fresh databases inside the same PostgreSQL 18.4 container. The workload contained 1,000 Endpoints, five direct tags per Endpoint (14 unique direct tags), and one inherited Product tag. Both runs used--batch-size 100 --progress-every 50 --benchmark --query-count.The patched runs had no tag or inheritance mismatches. After the rerun, all 6,000
Location.tagsrelationships, 1,000Location.inherited_tagsrelationships, and all 15 counters remained correct.This controlled workload is not a reproduction of the reporter's deployment and does not establish the same improvement for every tag distribution or at the full 65,194-Endpoint scale. The patch prevents new counter drift during this command; it does not repair counters that were already incorrect.
Documentation
No documentation change is needed because the command interface and workflow are unchanged.
Checklist
bugfixbranch.performance/bugfix.