Add added_between/removed_between filters for content diffs across arbitrary repository versions - #7844
Conversation
3b22794 to
ca2e6ba
Compare
3c005b4 to
423500f
Compare
|
We have fixed a couple of DB performance issues by switching to using subqueries. I foresee us doing this more broadly throughout the codebase. |
|
Here are some added insights to some of the performance concerns raised. I'm mainly trying to answer these two questions:
Tl;dr - the To review, (X's content)
If the existing And here are some benchmarks comparing all three scenarios. These are measured on a 200k-unit dataset with 1000-unit diff between repo versions. Results are taken over a 3-run average.
As the results show, optimizing The worrying part is where we would implement the fix for • The As an aside, I've also explored removing the 65535 content unit conditional on |
|
I've opened a draft PR on what subqueries for |
423500f to
d26aa99
Compare
|
copied from #7848; discussion should really happen here.
Exactly. That's what I meant with blueprint. The implementation of the RangeFilter was never going to help us. |
d26aa99 to
8f20834
Compare
|
My preference is always for designs that are more explicit in their behavior and explanation. So in this case I think |
Okay sure. Will work on using |
8f20834 to
df3edea
Compare
df3edea to
af6517a
Compare
|
@acheng-01 lint is failing |
|
@acheng-01 can you fix the lint issues and repush please? |
…bitrary repository versions This PR adds two range filters to the content viewset, added_between and removed_between, that compute the net content diff between two arbitrary (non-adjacent) repository versions, rather than only the single-step diff against the immediate predecessor that repository_version_added and repository_version_removed provide. Each filter takes exactly two comma-separated Repository Version (or Repository) HREF/PRNs in 'base,target' order. added_between=base,target returns the content present in target but not in base; removed_between=base,target returns the content present in base but not in target. The two are symmetric: added_between=a,b is equivalent to removed_between=b,a. Benchmarks on a synthetic 200k-unit system with 1000-unit diffs between repo versions show this approach is ~5-15x faster than running an equivalent complex q query, with the query going from 1486 ms -> 99 ms for a 50k/50k repo version pair and 2403 ms -> 479 ms for a 199k/199k repo version pair. Planning time also decreases significantly and stays ~0.2 ms. repository_version_added and repository_version_removed are unchanged and continue to compute the single-step diff against the immediate predecessor, preserving backward compatibility. Closes pulp#7831 Assisted by: Claude Opus 4.8
af6517a to
00eea57
Compare
|
|
||
| @staticmethod | ||
| def get_resource(uri, model=None): | ||
| def get_resource(uri, model=None, deferred_fields=None): |
There was a problem hiding this comment.
I'd like to handle the deferring differently (on the model/manager level not the view):
There was a problem hiding this comment.
@mdellweg I left a comment on your PR. I'm fine with your changes, but how would you like to proceed so that we don't conflict?
This PR adds two range filters to the content viewset, added_between and removed_between, that
compute the net content diff between two arbitrary (non-adjacent) repository versions, rather
than only the single-step diff against the immediate predecessor that repository_version_added
and repository_version_removed provide.
Each filter takes exactly two comma-separated Repository Version (or Repository) HREF/PRNs in
'base,target' order. added_between=base,target returns the content present in target but not in
base; removed_between=base,target returns the content present in base but not in target. The two
are symmetric: added_between=a,b is equivalent to removed_between=b,a.
Benchmarks on a synthetic 200k-unit system with 1000-unit diffs between repo versions show this
approach is ~5-15x faster than running an equivalent complex q query, with the query going from
1486 ms -> 99 ms for a 50k/50k repo version pair and 2403 ms -> 479 ms for a 199k/199k repo
version pair. Planning time also decreases significantly and stays ~0.2 ms.
repository_version_added and repository_version_removed are unchanged and continue to compute the
single-step diff against the immediate predecessor, preserving backward compatibility.
Closes #7831
Assisted by: Claude Opus 4.8
📜 Checklist
See: Pull Request Walkthrough