right now, VersioncontrolBranch::delete() with the 'nested' option will load ALL commits on that branch and iterate over them in PHP to see if they are on any other branches, and if not, then delete them. that means a potentially *huge* number of objects for large repositories, and we'd just be *asking* for memory exhaustion.

we need to see if we can optimize that logic so that the only commits that get loaded in the first place are the ones that need to be deleted. better to have one potentially expensive query than suddenly spike to 500MB of mem usage.

marking this major, as it is a nontrivial issue in making our syncEvent() logic fully accurate.

Comments

marvil07’s picture

Assigned: Unassigned » marvil07

I'll providing a patch soon.

marvil07’s picture

Assigned: marvil07 » sdboyer
Status: Active » Needs review
StatusFileSize
new2.33 KB

The patch. It works for some test cases I have locally.

@sdboyer: Do you mind taking another look at it before adding it to mainline?

sdboyer’s picture

i would prefer that we pass the call through the API rather than directly querying that table, if *at all* possible. so, adding a conditional on the loadCommits() call which adds the HAVING COUNT, etc. logic.

breaking that encapsulation creates technical debt later for any backend that wants to use an alternate storage mechanism. which, eventually, i do.

if it proves too difficult, we can go with this.

sdboyer’s picture

Status: Needs review » Needs work
marvil07’s picture

Status: Needs work » Fixed
StatusFileSize
new2.8 KB
new3.63 KB

I agree, breaking the encapsulation is a bad idea.

The problem that makes it not possible to do it through the controller load(), is that the query that has the group by clause is not on the base table(it's on versioncontrol_operation_labels).

The only way I see to solve this naturally, is to add a "VersioncontrolOperationLabels" entity and with it also an "VersioncontrolOperationLabelsController", so it is encapsulated there. But I am not convinced of that, since it is not really an entity as all the others we have.

So, I end up adding the custom queries on a special method at operation controller, so, it can be customized on other controllers.

I have added the attached patch to both 7.x-1.x and 6.x-2.x

marvil07’s picture

Assigned: sdboyer » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 3eedd60 on 7.x-1.x, repository-families, drush-vc-sync-unlock by marvil07:
    Issue #1642310: Optimize logic for branch deletion with nested option.
    

  • Commit 3eedd60 on 7.x-1.x, repository-families by marvil07:
    Issue #1642310: Optimize logic for branch deletion with nested option.